Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.net.URLConnection
java.net.HttpURLConnection
public abstract class HttpURLConnection
extends URLConnection
Field Summary | |
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
protected boolean |
|
protected String |
|
protected int |
|
protected String |
|
Fields inherited from class java.net.URLConnection | |
allowUserInteraction , connected , doInput , doOutput , ifModifiedSince , url , useCaches |
Constructor Summary | |
|
Method Summary | |
abstract void |
|
InputStream |
|
static boolean |
|
long |
|
boolean |
|
Permission |
|
String |
|
int |
|
String |
|
static void |
|
void |
|
void |
|
abstract boolean |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final int HTTP_ACCEPTED
The request has been accepted for processing but has not completed. There is no guarantee that the requested action will actually ever be completed succesfully, but everything is ok so far.
- Field Value:
- 202
public static final int HTTP_BAD_GATEWAY
The proxy encountered a bad response from the server it was proxy-ing for
- Field Value:
- 502
public static final int HTTP_BAD_METHOD
The specified request method is not allowed for this resource.
- Field Value:
- 405
public static final int HTTP_BAD_REQUEST
The request was misformed or could not be understood.
- Field Value:
- 400
public static final int HTTP_CLIENT_TIMEOUT
The request timed out.
- Field Value:
- 408
public static final int HTTP_CONFLICT
There is a conflict between the current state of the resource and the requested action.
- Field Value:
- 409
public static final int HTTP_CREATED
The requested resource has been created.
- Field Value:
- 201
public static final int HTTP_ENTITY_TOO_LARGE
The request sent was too large for the server to handle.
- Field Value:
- 413
public static final int HTTP_FORBIDDEN
There is no permission to access the requested resource.
- Field Value:
- 403
public static final int HTTP_GATEWAY_TIMEOUT
The proxy timed out getting a reply from the remote server it was proxy-ing for.
- Field Value:
- 504
public static final int HTTP_GONE
The requested resource is no longer available. This ususally indicates a permanent condition.
- Field Value:
- 410
public static final int HTTP_INTERNAL_ERROR
The server encountered an unexpected error (such as a CGI script crash) that prevents the request from being fulfilled.
- Field Value:
- 500
public static final int HTTP_LENGTH_REQUIRED
A Content-Length header is required for this request, but was not supplied.
- Field Value:
- 411
public static final int HTTP_MOVED_PERM
The resource has been permanently moved to a new location.
- Field Value:
- 301
public static final int HTTP_MOVED_TEMP
The resource requested has been temporarily moved to a new location.
- Field Value:
- 302
public static final int HTTP_MULT_CHOICE
There is a list of choices available for the requested resource.
- Field Value:
- 300
public static final int HTTP_NOT_ACCEPTABLE
Based on the input headers sent, the resource returned in response to the request would not be acceptable to the client.
- Field Value:
- 406
public static final int HTTP_NOT_AUTHORITATIVE
The meta-information returned in the header is not the actual data from the original server, but may be from a local or other copy. Normally this still indicates a successful completion.
- Field Value:
- 203
public static final int HTTP_NOT_FOUND
The requested resource was not found.
- Field Value:
- 404
public static final int HTTP_NOT_IMPLEMENTED
The server does not support the requested functionality.
- Field Value:
- 501
- Since:
- 1.3
public static final int HTTP_NOT_MODIFIED
The document has not been modified since the criteria specified in a conditional GET.
- Field Value:
- 304
public static final int HTTP_NO_CONTENT
The server performed the request, but there is no data to send back. This indicates that the user's display should not be changed.
- Field Value:
- 204
public static final int HTTP_PARTIAL
The server completed the partial GET request for the resource.
- Field Value:
- 206
public static final int HTTP_PAYMENT_REQUIRED
Code reserved for future use - I hope way in the future.
- Field Value:
- 402
public static final int HTTP_PRECON_FAILED
A client specified pre-condition was not met on the server.
- Field Value:
- 412
public static final int HTTP_PROXY_AUTH
The client must authenticate with a proxy prior to attempting this request.
- Field Value:
- 407
public static final int HTTP_REQ_TOO_LONG
The name of the resource specified was too long.
- Field Value:
- 414
public static final int HTTP_RESET
The server performed the request, but there is no data to sent back, however, the user's display should be "reset" to clear out any form fields entered.
- Field Value:
- 205
public static final int HTTP_SEE_OTHER
The response to the request issued is available at another location.
- Field Value:
- 303
public static final int HTTP_SERVER_ERROR
Deprecated.
This error code indicates that some sort of server error occurred.
- Field Value:
- 500
public static final int HTTP_UNAUTHORIZED
The request made requires user authorization. Try again with a correct authentication header.
- Field Value:
- 401
public static final int HTTP_UNAVAILABLE
The HTTP service is not availalble, such as because it is overloaded and does not want additional requests.
- Field Value:
- 503
public static final int HTTP_UNSUPPORTED_TYPE
The request is in a format not supported by the requested resource.
- Field Value:
- 415
public static final int HTTP_USE_PROXY
The requested resource needs to be accessed through a proxy.
- Field Value:
- 305
public static final int HTTP_VERSION
This server does not support the protocol version requested.
- Field Value:
- 505
protected boolean instanceFollowRedirects
If this instance should follow redirect requests.
protected String responseMessage
The response message string received from the server.
protected HttpURLConnection(URL url)
Create an HttpURLConnection for the specified URL
- Parameters:
url
- The URL to create this connection for.
public InputStream getErrorStream()
This method allows the caller to retrieve any data that might have been sent despite the fact that an error occurred. For example, the HTML page sent along with a 404 File Not Found error. If the socket is not connected, or if no error occurred or no data was returned, this method returnsnull
.
- Returns:
- An
InputStream
for reading error data.
public static boolean getFollowRedirects()
Returns a boolean indicating whether or not HTTP redirects will automatically be followed or not.
- Returns:
- true if redirects will be followed, false otherwise
public long getHeaderFieldDate(String key, long value)
Returns the value of the named field parsed as date
- Overrides:
- getHeaderFieldDate in interface URLConnection
- Parameters:
key
- the key of the header fieldvalue
- the default value if the header field is not present
- Returns:
- the value of the header field
public boolean getInstanceFollowRedirects()
Returns the value of this HttpURLConnection's instanceFollowRedirects field
- Returns:
- true if following redirects is enabled, false otherwise
public Permission getPermission() throws IOException
Returns a permission object representing the permission necessary to make the connection represented by this object
- Overrides:
- getPermission in interface URLConnection
- Returns:
- the permission necessary for this connection
- Throws:
IOException
- If an error occurs
public String getRequestMethod()
The request method currently in use for this connection.
- Returns:
- The request method
public int getResponseCode() throws IOException
Gets the status code from an HTTP response message, or -1 if the response code could not be determined. Note that all valid response codes have class variables defined for them in this class.
- Returns:
- The response code
- Throws:
IOException
- If an error occurs
public String getResponseMessage() throws IOException
Gets the HTTP response message, if any, returned along with the response code from a server. Null if no response message was set or an error occured while connecting.
- Returns:
- The response message
- Throws:
IOException
- If an error occurs
public static void setFollowRedirects(boolean set)
Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this class. True by default
- Parameters:
set
- true if redirects should be followed, false otherwis.
- Throws:
SecurityException
- If a security manager exists and its checkSetFactory method doesn't allow the operation
public void setInstanceFollowRedirects(boolean follow)
Sets the value of this HttpURLConnection's instanceFollowRedirects field
- Parameters:
follow
- true to enable following redirects, false otherwise
public void setRequestMethod(String method) throws ProtocolException
Set the method for the URL request, one of: GET POST HEAD OPTIONS PUT DELETE TRACE are legal
- Parameters:
method
- the method to use
- Throws:
ProtocolException
- If the method cannot be reset or if the requested method isn't valid for HTTP
public abstract boolean usingProxy()
Returns a boolean indicating whether or not this connection is going through a proxy
- Returns:
- true if through a proxy, false otherwise