java.lang.Object | |||
java.net.URLConnection | |||
java.net.HttpURLConnection |
This abstract subclass of URLConnection
defines method for
managing HTTP connection according to the description given by RFC 2068
Value | ||||
---|---|---|---|---|
int | HTTP_ACCEPTED | Numeric status code, 202: Accepted | 202 | 0x000000ca |
int | HTTP_BAD_GATEWAY | Numeric status code, 502: Bad Gateway | 502 | 0x000001f6 |
int | HTTP_BAD_METHOD | Numeric status code, 405: Bad Method | 405 | 0x00000195 |
int | HTTP_BAD_REQUEST | Numeric status code, 400: Bad Request | 400 | 0x00000190 |
int | HTTP_CLIENT_TIMEOUT | Numeric status code, 408: Client Timeout | 408 | 0x00000198 |
int | HTTP_CONFLICT | Numeric status code, 409: Conflict | 409 | 0x00000199 |
int | HTTP_CREATED | Numeric status code, 201: Created | 201 | 0x000000c9 |
int | HTTP_ENTITY_TOO_LARGE | Numeric status code, 413: Entity too large | 413 | 0x0000019d |
int | HTTP_FORBIDDEN | Numeric status code, 403: Forbidden | 403 | 0x00000193 |
int | HTTP_GATEWAY_TIMEOUT | Numeric status code, 504: Gateway timeout | 504 | 0x000001f8 |
int | HTTP_GONE | Numeric status code, 410: Gone | 410 | 0x0000019a |
int | HTTP_INTERNAL_ERROR | Numeric status code, 500: Internal error | 500 | 0x000001f4 |
int | HTTP_LENGTH_REQUIRED | Numeric status code, 411: Length required | 411 | 0x0000019b |
int | HTTP_MOVED_PERM | Numeric status code, 301 Moved permanently | 301 | 0x0000012d |
int | HTTP_MOVED_TEMP | Numeric status code, 302: Moved temporarily | 302 | 0x0000012e |
int | HTTP_MULT_CHOICE | Numeric status code, 300: Multiple choices | 300 | 0x0000012c |
int | HTTP_NOT_ACCEPTABLE | Numeric status code, 406: Not acceptable | 406 | 0x00000196 |
int | HTTP_NOT_AUTHORITATIVE | Numeric status code, 203: Not authoritative | 203 | 0x000000cb |
int | HTTP_NOT_FOUND | Numeric status code, 404: Not found | 404 | 0x00000194 |
int | HTTP_NOT_IMPLEMENTED | Numeric status code, 501: Not implemented | 501 | 0x000001f5 |
int | HTTP_NOT_MODIFIED | Numeric status code, 304: Not modified | 304 | 0x00000130 |
int | HTTP_NO_CONTENT | Numeric status code, 204: No content | 204 | 0x000000cc |
int | HTTP_OK | Numeric status code, 200: OK | 200 | 0x000000c8 |
int | HTTP_PARTIAL | Numeric status code, 206: Partial | 206 | 0x000000ce |
int | HTTP_PAYMENT_REQUIRED | Numeric status code, 402: Payment required | 402 | 0x00000192 |
int | HTTP_PRECON_FAILED | Numeric status code, 412: Precondition failed | 412 | 0x0000019c |
int | HTTP_PROXY_AUTH | Numeric status code, 407: Proxy authentication required | 407 | 0x00000197 |
int | HTTP_REQ_TOO_LONG | Numeric status code, 414: Request too long | 414 | 0x0000019e |
int | HTTP_RESET | Numeric status code, 205: Reset | 205 | 0x000000cd |
int | HTTP_SEE_OTHER | Numeric status code, 303: See other | 303 | 0x0000012f |
int | HTTP_SERVER_ERROR | This constant is deprecated. Use HTTP_INTERNAL_ERROR | 500 | 0x000001f4 |
int | HTTP_UNAUTHORIZED | Numeric status code, 401: Unauthorized | 401 | 0x00000191 |
int | HTTP_UNAVAILABLE | Numeric status code, 503: Unavailable | 503 | 0x000001f7 |
int | HTTP_UNSUPPORTED_TYPE | Numeric status code, 415: Unsupported type | 415 | 0x0000019f |
int | HTTP_USE_PROXY | Numeric status code, 305: Use proxy | 305 | 0x00000131 |
int | HTTP_VERSION | Numeric status code, 505: Version not supported | 505 | 0x000001f9 |
protected | int | chunkLength | |||
protected | int | fixedContentLength | |||
protected | boolean | instanceFollowRedirects | |||
protected | String | method | |||
protected | int | responseCode | |||
protected | String | responseMessage |
HttpURLConnection(URL url) | ||||||
Constructs a HttpURLConnection pointing to the resource
specified by the URL . |
abstract | void | disconnect() | ||||
Closes the connection with the HTTP server | ||||||
InputStream | getErrorStream() | |||||
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. | ||||||
static | boolean | getFollowRedirects() | ||||
Returns the value of followRedirects which indicates if
this connection will follows a different URL redirected by the server. |
||||||
long | getHeaderFieldDate(String field, long defaultValue) | |||||
Returns the date value in the form of milliseconds since epoch
corresponding to the field field . |
||||||
boolean | getInstanceFollowRedirects() | |||||
Returns if this connection follows redirects. | ||||||
Permission | getPermission() | |||||
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. | ||||||
String | getRequestMethod() | |||||
Returns the request method which will be used to make the request to the remote HTTP server. | ||||||
int | getResponseCode() | |||||
Returns the response code returned by the remote HTTP server | ||||||
String | getResponseMessage() | |||||
Returns the response message returned the remote HTTP server | ||||||
void | setChunkedStreamingMode(int chunklen) | |||||
If length of a HTTP request body is NOT known ahead, enable chunked transfer encoding to enable streaming without buffering. | ||||||
void | setFixedLengthStreamingMode(int contentLength) | |||||
If length of a HTTP request body is known ahead, sets fixed length to enable streaming without buffering. | ||||||
static | void | setFollowRedirects(boolean auto) | ||||
Sets the flag of whether this connection will follow redirects returned by the remote server. | ||||||
void | setInstanceFollowRedirects(boolean followRedirects) | |||||
Sets if this connection follows redirects. | ||||||
void | setRequestMethod(String method) | |||||
Sets the request command which will be sent to the remote HTTP server. | ||||||
abstract | boolean | usingProxy() | ||||
Returns if this connection uses proxy. |
HttpURLConnection
pointing to the resource
specified by the URL
.
url | the URL of this connection |
---|
If the content type is not what stated above,
FileNotFoundException
is thrown.
followRedirects
which indicates if
this connection will follows a different URL redirected by the server. It
is enabled by default.
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 |
IOException | if an IO exception occurs during the creation of the permission object. |
---|
IOException | if there is an IO error during the retrieval. |
---|
null
if such response existsIOException | if there is an IO error during the retrieval. |
---|
chunklen | the length of a chunk |
---|
IllegalStateException | if already connected or other mode already set |
---|
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 |
auto | The value to set |
---|
followRedirects | true if this connection should follows redirects, false otherwise. |
---|
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. |
---|
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:56 |