java.net.HttpURLConnection
java.net.URLConnection
None
None
New as of JDK 1.1
The HttpURLConnection class is an abstract class that is a subclass of URLConnection. HttpURLConnection defines many of the HTTP server response codes as constants and provides methods for parsing server responses.
An HttpURLConnection object defines a network connection to a resource specified by a URL. Essentially, the HttpURLConnection object represents the HTTP request for that resource.
public abstract class java.net.HttpURLConnection extends java.net.URLConnection { // Constants public final static int HTTP_ACCEPTED; public final static int HTTP_BAD_GATEWAY; public final static int HTTP_BAD_METHOD; public final static int HTTP_BAD_REQUEST; public final static int HTTP_CLIENT_TIMEOUT; public final static int HTTP_CONFLICT; public final static int HTTP_CREATED; public final static int HTTP_ENTITY_TOO_LARGE; public final static int HTTP_FORBIDDEN; public final static int HTTP_GATEWAY_TIMEOUT; public final static int HTTP_GONE; public final static int HTTP_INTERNAL_ERROR; public final static int HTTP_LENGTH_REQUIRED; public final static int HTTP_MOVED_PERM; public final static int HTTP_MOVED_TEMP; public final static int HTTP_MULT_CHOICE; public final static int HTTP_NOT_ACCEPTABLE; public final static int HTTP_NOT_AUTHORITATIVE; public final static int HTTP_NOT_FOUND; public final static int HTTP_NOT_MODIFIED; public final static int HTTP_NO_CONTENT; public final static int HTTP_OK; public final static int HTTP_PARTIAL; public final static int HTTP_PAYMENT_REQUIRED; public final static int HTTP_PRECON_FAILED; public final static int HTTP_PROXY_AUTH; public final static int HTTP_REQ_TOO_LONG; public final static int HTTP_RESET; public final static int HTTP_SEE_OTHER; public final static int HTTP_SERVER_ERROR; public final static int HTTP_UNAUTHORIZED; public final static int HTTP_UNAVAILABLE; public final static int HTTP_UNSUPPORTED_TYPE; public final static int HTTP_USE_PROXY; public final static int HTTP_VERSION; // Variables protected String method; protected int responseCode; protected String responseMessage; // Constructors protected HttpURLConnection(URL u); // Class Methods public static boolean getFollowRedirects(); public static void setFollowRedirects(boolean set); // Instance Methods public abstract void disconnect(); public String getRequestMethod(); public int getResponseCode(); public String getResponseMessage(); public void setRequestMethod(String method); public abstract boolean usingProxy(); }
The HTTP response code that means the request has been accepted by the server.
The HTTP response code that means the server, acting as a gateway, has received a bad response from another server.
The HTTP response code that means the requested method is not allowed for the requested resource.
The HTTP response code that means the request was syntactically incorrect.
The HTTP response code that means the server has not received a request from the client in the time it expected.
The HTTP response code that means there is a conflict with the state of the requested resource.
The HTTP response code that means a new resource has been created as the result of the request.
The HTTP response code that means the request contains an entity that is too large for the server.
The HTTP response code that means the client does not have permission to access the requested resource.
The HTTP response code that means the server, acting as a gateway, has not received a response from an upstream server in the time it expected.
The HTTP response code that means the requested resource is no longer available.
The HTTP response code that means the server does not or cannot support the client's request.
The HTTP response code that means the server won't accept the request without a length indication.
The HTTP response code that means the requested resource has moved permanently.
The HTTP response code that means the requested resource has moved temporarily.
The HTTP response code that means the requested resource is available in multiple representations.
The HTTP response code that means the requested resource is not available in a representation that is acceptable to the client.
The HTTP response code that means the information returned may be a copy.
The HTTP response code that means the server could not find the requested resource.
The HTTP response code that means the requested resource has not been modified.
The HTTP response code that means the request has been processed, but there is no new information.
The HTTP response code that means the request succeeded.
The HTTP response code that means the partial request has been fulfilled.
An HTTP response code that is reserved for future use.
The HTTP response code that means the precondition in the request has failed.
The HTTP response code that means the client needs to authenticate itself with the proxy.
The HTTP response code that means the client request is too long.
The HTTP response code that means the request has been fulfilled, and the client should reset its view.
The HTTP response code that means the requested resource is available at another URL.
The HTTP response code that means the server encountered a problem and could not fulfill the request.
The HTTP response code that means the client is not authenticated for the requested resource.
The HTTP response code that means the server is temporarily unable to fulfill the request.
The HTTP response code that means the server cannot process the type of the request.
The HTTP response code that means a proxy must be used to access the requested resource.
The HTTP response code that means the server does not support the HTTP version used in the request.
The method of this request. Valid values are: "DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT", and "TRACE".
The response code from the server, which may be one of the HTTP_ constants.
The response message from the server that corresponds to responseCode.
A URL object that represents a resource.
This constructor creates an HttpURLConnection for the given URL object.
A boolean value that indicates whether or not HTTP redirect codes are automatically followed.
This method indicates whether or not this HttpURLConnection follows HTTP redirects. The default value is false.
A boolean value that specifies whether or not HTTP redirects should be followed.
If there is a SecurityManager installed and its checkSetFactory() method throws a SecurityException.
This method specifies whether or not this HttpURLConnection follows HTTP redirects.
This method closes the connection to the server.
The method of this request.
This method returns the method of this request.
The response code from the server.
If any kind of I/O error occurs.
This method returns the code the server sent in response to this request. For example, suppose the server response is:
HTTP/1.0 404 Not Found
In this case, the method returns integer value 404.
The response message from the server.
If any kind of I/O error occurs.
This method returns the message the server sent in response to this request. For example, suppose the server response is:
HTTP/1.0 404 Not Found
In this case, the method returns the string "Not Found".
public void setRequestMethod(String method) throws ProtocolException
The new method for this request.
If the connection has already been made or if method is invalid.
This method sets the method of this request. Valid values are: "DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT", and "TRACE".
A boolean value that indicates whether or not this HttpURLConnection is using a proxy.
If any kind of I/O error occurs.
This method returns a flag that indicates if this connection is going through a proxy or not.
Variable |
Inherited From |
Variable |
Inherited From |
---|---|---|---|
allowUserInteraction |
URLConnection |
connected |
URLConnection |
doInput |
URLConnection |
doOutput |
URLConnection |
ifModifiedSince |
URLConnection |
url |
URLConnection |
useCaches |
URLConnection |
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
connect() |
URLConnection |
equals(Object) |
Object |
finalize() |
Object |
getAllowUserInteraction() |
URLConnection |
getClass() |
Object |
getContent() |
URLConnection |
getContentEncoding() |
URLConnection |
getContentLength() |
URLConnection |
getContentType() |
URLConnection |
getDate() |
URLConnection |
getDefaultUseCaches() |
URLConnection |
getDoInput() |
URLConnection |
getDoOutput() |
URLConnection |
getExpiration() |
URLConnection |
getHeaderField(String) |
URLConnection |
getHeaderField(int) |
URLConnection |
getHeaderFieldDate(String, long) |
URLConnection |
getHeaderFieldInt(String, int) |
URLConnection |
getHeaderFieldKey(int) |
URLConnection |
getIfModifiedSince() |
URLConnection |
getInputStream() |
URLConnection |
getLastModified() |
URLConnection |
getOutputStream() |
URLConnection |
getRequestProperty(String) |
URLConnection |
getURL() |
URLConnection |
getUseCaches() |
URLConnection |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
setAllowUserInteraction(boolean) |
URLConnection |
setDefaultUseCaches(boolean) |
URLConnection |
setDoInput(boolean) |
URLConnection |
setDoOutput(boolean) |
URLConnection |
setIfModifiedSince(long) |
URLConnection |
setRequestProperty(String, String) |
URLConnection |
setUseCaches(boolean) |
URLConnection |
toString() |
URLConnection |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
IOException, ProtocolException, SecurityException, SecurityManager, URL, URLConnection
This HTML Help has been published using the chm2web software. |