| java.lang.Object | ||
| ↳ | java.net.URLConnection | |
| ↳ | java.net.HttpURLConnection | |
Known Direct Subclasses
|
This abstract subclass of URLConnection defines method for
managing HTTP connection according to the description given by RFC 2068
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | HTTP_ACCEPTED | Numeric status code, 202: Accepted | |||||||||
| int | HTTP_BAD_GATEWAY | Numeric status code, 502: Bad Gateway | |||||||||
| int | HTTP_BAD_METHOD | Numeric status code, 405: Bad Method | |||||||||
| int | HTTP_BAD_REQUEST | Numeric status code, 400: Bad Request | |||||||||
| int | HTTP_CLIENT_TIMEOUT | Numeric status code, 408: Client Timeout | |||||||||
| int | HTTP_CONFLICT | Numeric status code, 409: Conflict | |||||||||
| int | HTTP_CREATED | Numeric status code, 201: Created | |||||||||
| int | HTTP_ENTITY_TOO_LARGE | Numeric status code, 413: Entity too large | |||||||||
| int | HTTP_FORBIDDEN | Numeric status code, 403: Forbidden | |||||||||
| int | HTTP_GATEWAY_TIMEOUT | Numeric status code, 504: Gateway timeout | |||||||||
| int | HTTP_GONE | Numeric status code, 410: Gone | |||||||||
| int | HTTP_INTERNAL_ERROR | Numeric status code, 500: Internal error | |||||||||
| int | HTTP_LENGTH_REQUIRED | Numeric status code, 411: Length required | |||||||||
| int | HTTP_MOVED_PERM | Numeric status code, 301 Moved permanently | |||||||||
| int | HTTP_MOVED_TEMP | Numeric status code, 302: Moved temporarily | |||||||||
| int | HTTP_MULT_CHOICE | Numeric status code, 300: Multiple choices | |||||||||
| int | HTTP_NOT_ACCEPTABLE | Numeric status code, 406: Not acceptable | |||||||||
| int | HTTP_NOT_AUTHORITATIVE | Numeric status code, 203: Not authoritative | |||||||||
| int | HTTP_NOT_FOUND | Numeric status code, 404: Not found | |||||||||
| int | HTTP_NOT_IMPLEMENTED | Numeric status code, 501: Not implemented | |||||||||
| int | HTTP_NOT_MODIFIED | Numeric status code, 304: Not modified | |||||||||
| int | HTTP_NO_CONTENT | Numeric status code, 204: No content | |||||||||
| int | HTTP_OK | Numeric status code, 200: OK | |||||||||
| int | HTTP_PARTIAL | Numeric status code, 206: Partial | |||||||||
| int | HTTP_PAYMENT_REQUIRED | Numeric status code, 402: Payment required | |||||||||
| int | HTTP_PRECON_FAILED | Numeric status code, 412: Precondition failed | |||||||||
| int | HTTP_PROXY_AUTH | Numeric status code, 407: Proxy authentication required | |||||||||
| int | HTTP_REQ_TOO_LONG | Numeric status code, 414: Request too long | |||||||||
| int | HTTP_RESET | Numeric status code, 205: Reset | |||||||||
| int | HTTP_SEE_OTHER | Numeric status code, 303: See other | |||||||||
| int | HTTP_SERVER_ERROR | This constant is deprecated. Use HTTP_INTERNAL_ERROR | |||||||||
| int | HTTP_UNAUTHORIZED | Numeric status code, 401: Unauthorized | |||||||||
| int | HTTP_UNAVAILABLE | Numeric status code, 503: Unavailable | |||||||||
| int | HTTP_UNSUPPORTED_TYPE | Numeric status code, 415: Unsupported type | |||||||||
| int | HTTP_USE_PROXY | Numeric status code, 305: Use proxy | |||||||||
| int | HTTP_VERSION | Numeric status code, 505: Version not supported | |||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| chunkLength | |||||||||||
| fixedContentLength | |||||||||||
| instanceFollowRedirects | |||||||||||
| method | |||||||||||
| responseCode | |||||||||||
| responseMessage | |||||||||||
|
[Expand]
Inherited Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.net.URLConnection
| |||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a
HttpURLConnection pointing to the resource
specified by the URL. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Closes the connection with the HTTP server
| |||||||||||
Returns a input stream from the server in the case of error such as the
requested file (txt, htm, html) is not found on the remote server.
| |||||||||||
Returns the value of
followRedirects which indicates if
this connection will follows a different URL redirected by the server. | |||||||||||
Returns the date value in the form of milliseconds since epoch
corresponding to the field
field. | |||||||||||
Returns if this connection follows redirects.
| |||||||||||
Returns the permission object (in this case, SocketPermission) with the
host and the port number as the target name and "resolve, connect" as the
action list.
| |||||||||||
Returns the request method which will be used to make the request to the
remote HTTP server.
| |||||||||||
Returns the response code returned by the remote HTTP server
| |||||||||||
Returns the response message returned the remote HTTP server
| |||||||||||
If length of a HTTP request body is NOT known ahead, enable chunked
transfer encoding to enable streaming without buffering.
| |||||||||||
If length of a HTTP request body is known ahead, sets fixed length to
enable streaming without buffering.
| |||||||||||
Sets the flag of whether this connection will follow redirects returned
by the remote server.
| |||||||||||
Sets if this connection follows redirects.
| |||||||||||
Sets the request command which will be sent to the remote HTTP server.
| |||||||||||
Returns if this connection uses proxy.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.net.URLConnection
| |||||||||||
From class java.lang.Object
| |||||||||||
Numeric status code, 202: Accepted
Numeric status code, 502: Bad Gateway
Numeric status code, 405: Bad Method
Numeric status code, 400: Bad Request
Numeric status code, 408: Client Timeout
Numeric status code, 409: Conflict
Numeric status code, 201: Created
Numeric status code, 413: Entity too large
Numeric status code, 403: Forbidden
Numeric status code, 504: Gateway timeout
Numeric status code, 410: Gone
Numeric status code, 500: Internal error
Numeric status code, 411: Length required
Numeric status code, 301 Moved permanently
Numeric status code, 302: Moved temporarily
Numeric status code, 300: Multiple choices
Numeric status code, 406: Not acceptable
Numeric status code, 203: Not authoritative
Numeric status code, 404: Not found
Numeric status code, 501: Not implemented
Numeric status code, 304: Not modified
Numeric status code, 204: No content
Numeric status code, 200: OK
Numeric status code, 206: Partial
Numeric status code, 402: Payment required
Numeric status code, 412: Precondition failed
Numeric status code, 407: Proxy authentication required
Numeric status code, 414: Request too long
Numeric status code, 205: Reset
Numeric status code, 303: See other
Numeric status code, 401: Unauthorized
Numeric status code, 503: Unavailable
Numeric status code, 415: Unsupported type
Numeric status code, 305: Use proxy
Numeric status code, 505: Version not supported
Constructs a HttpURLConnection pointing to the resource
specified by the URL.
| url | the URL of this connection |
|---|
Returns a input stream from the server in the case of error such as the requested file (txt, htm, html) is not found on the remote server.
If the content type is not what stated above,
FileNotFoundException is thrown.
Returns the value of followRedirects which indicates if
this connection will follows a different URL redirected by the server. It
is enabled by default.
Returns the date value in the form of milliseconds since epoch
corresponding to the field field. Returns
defaultValue if no such field can be found in the response
header.
| field | the field in question |
|---|---|
| defaultValue | the default value if no field is found |
Returns if this connection follows redirects.
Returns the permission object (in this case, SocketPermission) with the host and the port number as the target name and "resolve, connect" as the action list.
| IOException | if an IO exception occurs during the creation of the permission object. |
|---|
Returns the request method which will be used to make the request to the remote HTTP server. All possible methods of this HTTP implementation is listed in the class definition.
Returns the response code returned by the remote HTTP server
| IOException | if there is an IO error during the retrieval. |
|---|
Returns the response message returned the remote HTTP server
null if such response exists| IOException | if there is an IO error during the retrieval. |
|---|
If length of a HTTP request body is NOT known ahead, enable chunked transfer encoding to enable streaming without buffering. Notice that not all http servers support this mode. Sets after connection will cause an exception.
| chunklen | the length of a chunk |
|---|
| IllegalStateException | if already connected or other mode already set |
|---|
If length of a HTTP request body is known ahead, sets fixed length to enable streaming without buffering. Sets after connection will cause an exception.
| contentLength | the fixed length of the HTTP request body |
|---|
| IllegalStateException | if already connected or other mode already set |
|---|---|
| IllegalArgumentException | if contentLength is less than zero |
Sets the flag of whether this connection will follow redirects returned by the remote server. This method can only be called with the permission from the security manager
| auto | The value to set |
|---|
Sets if this connection follows redirects.
| followRedirects | true if this connection should follows redirects, false otherwise. |
|---|
Sets the request command which will be sent to the remote HTTP server. This method can only be called before the connection is made.
| method | The non-null string representing the method |
|---|
| ProtocolException | Thrown when this is called after connected, or the method is not supported by this HTTP implementation. |
|---|
Returns if this connection uses proxy.