|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.net.URLConnection | +--java.net.HttpURLConnection | +--zyh.net.http.HttpURLConnection
HttpURLConnection class implements java.net.HttpURLConnection
HttpURLConnection
Fields inherited from class java.net.HttpURLConnection |
HTTP_ACCEPTED,
HTTP_BAD_GATEWAY,
HTTP_BAD_METHOD,
HTTP_BAD_REQUEST,
HTTP_CLIENT_TIMEOUT,
HTTP_CONFLICT,
HTTP_CREATED,
HTTP_ENTITY_TOO_LARGE,
HTTP_FORBIDDEN,
HTTP_GATEWAY_TIMEOUT,
HTTP_GONE,
HTTP_INTERNAL_ERROR,
HTTP_LENGTH_REQUIRED,
HTTP_MOVED_PERM,
HTTP_MOVED_TEMP,
HTTP_MULT_CHOICE,
HTTP_NO_CONTENT,
HTTP_NOT_ACCEPTABLE,
HTTP_NOT_AUTHORITATIVE,
HTTP_NOT_FOUND,
HTTP_NOT_MODIFIED,
HTTP_OK,
HTTP_PARTIAL,
HTTP_PAYMENT_REQUIRED,
HTTP_PRECON_FAILED,
HTTP_PROXY_AUTH,
HTTP_REQ_TOO_LONG,
HTTP_RESET,
HTTP_SEE_OTHER,
HTTP_SERVER_ERROR,
HTTP_UNAUTHORIZED,
HTTP_UNAVAILABLE,
HTTP_UNSUPPORTED_TYPE,
HTTP_USE_PROXY,
HTTP_VERSION,
method,
responseCode,
responseMessage |
Fields inherited from class java.net.URLConnection |
allowUserInteraction,
connected,
doInput,
doOutput,
ifModifiedSince,
url,
useCaches |
Constructor Summary | |
HttpURLConnection(java.net.URL url)
Constructor for HttpURLConnection object. |
|
HttpURLConnection(java.net.URL url,
java.lang.String mailbox)
Constructor for HttpURLConnection object. |
|
HttpURLConnection(java.net.URL url,
java.lang.String mailbox,
java.net.InetAddress proxyInetAddress,
int proxyPort)
Constructor for HttpURLConnection object. |
Method Summary | |
void |
connect()
Opens a communications link to the resource referenced by this URL, if such a connection has not already been established. |
void |
disconnect()
Close the connection to the server. |
static java.lang.String |
getDefaultRequestProperty(java.lang.String key)
Returns the value of the default request property. |
java.io.InputStream |
getErrorStream()
Returns the error stream if the doHTTPConnect failed but the server sent useful data nonetheless. |
java.lang.String |
getHeaderField(int n)
Returns the value for the n th header field.
|
java.lang.String |
getHeaderField(java.lang.String name)
Returns the name of the specified header field. |
java.lang.String |
getHeaderFieldKey(int n)
Returns the key for the n th header field. |
java.io.InputStream |
getInputStream()
Returns an input stream that reads from this open connection. |
java.io.PrintStream |
getLog()
Gets the log stream. |
java.io.OutputStream |
getOutputStream()
Returns an output stream that writes to this connection. |
java.lang.String |
getRequestProperty(java.lang.String key)
Returns the value of the named general request property for this doHTTPConnect. |
java.net.URL |
getURL()
|
void |
log(java.lang.String msg)
Prints a message to the current log stream. |
static void |
main(java.lang.String[] args)
A simple test application |
static void |
setDefaultRequestProperty(java.lang.String key,
java.lang.String value)
Sets the default value of a general request property. |
void |
setLog(java.io.PrintStream logStream)
|
void |
setRequestProperty(java.lang.String key,
java.lang.String value)
Sets the general request property. |
boolean |
usingProxy()
Indicates if the connection is going through a proxy. |
Methods inherited from class java.net.HttpURLConnection |
getFollowRedirects,
getPermission,
getRequestMethod,
getResponseCode,
getResponseMessage,
setFollowRedirects,
setRequestMethod |
Methods inherited from class java.net.URLConnection |
getAllowUserInteraction,
getContent,
getContentEncoding,
getContentLength,
getContentType,
getDate,
getDefaultAllowUserInteraction,
getDefaultUseCaches,
getDoInput,
getDoOutput,
getExpiration,
getFileNameMap,
getHeaderFieldDate,
getHeaderFieldInt,
getIfModifiedSince,
getLastModified,
getUseCaches,
guessContentTypeFromName,
guessContentTypeFromStream,
setAllowUserInteraction,
setContentHandlerFactory,
setDefaultAllowUserInteraction,
setDefaultUseCaches,
setDoInput,
setDoOutput,
setFileNameMap,
setIfModifiedSince,
setUseCaches,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public HttpURLConnection(java.net.URL url) throws java.net.MalformedURLException
url
- the destination urlpublic HttpURLConnection(java.net.URL url, java.lang.String mailbox) throws java.net.MalformedURLException
url
- the destination urlmailbox
- please provide your mailbox so that server maintainers can contact you in case of problemspublic HttpURLConnection(java.net.URL url, java.lang.String mailbox, java.net.InetAddress proxyInetAddress, int proxyPort) throws java.net.MalformedURLException
url
- the destination urlmailbox
- please provide your mailbox so that server maintainers can contact you in case of problemsproxyInetAddress
- the InetAddress of HTTP proxyproxyPort
- the port of HTTP proxyMethod Detail |
public java.net.URL getURL()
public java.io.InputStream getInputStream() throws java.io.IOException
public java.io.OutputStream getOutputStream() throws java.io.IOException
public void setLog(java.io.PrintStream logStream)
public java.io.PrintStream getLog()
public void log(java.lang.String msg)
message
- a log or tracing messagepublic boolean usingProxy()
public void disconnect()
public void connect() throws java.io.IOException
public java.lang.String getHeaderField(java.lang.String name)
name
- the name of a header field.null
if there is no such field in the header.public java.lang.String getHeaderFieldKey(int n)
n
th header field.n
- an index.n
th header field,
or null
if there are fewer than n
fields.public java.lang.String getHeaderField(int n)
n
th header field.
It returns null
if there are fewer than
n
fields.
This method can be used in conjunction with the
getHeaderFieldKey
method to iterate through all
the headers in the message.
n
- an index.n
th header field.URLConnection.getHeaderFieldKey(int)
public java.lang.String getRequestProperty(java.lang.String key)
public void setRequestProperty(java.lang.String key, java.lang.String value)
key
- the keyword by which the request is known
(e.g., "accept
").value
- the value associated with it.public static void setDefaultRequestProperty(java.lang.String key, java.lang.String value)
URLConnection
is created, it is initialized with
these properties.key
- the keyword by which the request is known
(e.g., "accept
").value
- the value associated with the key.public static java.lang.String getDefaultRequestProperty(java.lang.String key)
URLConnection.setDefaultRequestProperty(java.lang.String, java.lang.String)
public java.io.InputStream getErrorStream()
This method will not cause a doHTTPConnect to be initiated. If there the doHTTPConnect was not connected, or if the server did not have an error while connecting or if the server did have an error but there no error data was sent, this method will return null. This is the default.
public static void main(java.lang.String[] args) throws java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |