java.net.HttpURLConnection (JDK 1.1)
This class is a specialization of URLConnection. An instance of this class is returned when the openConnection() method is called for a URL object that uses the HTTP protocol.
The many constants defined by this class are the status codes returned by HTTP servers. setRequestMethod() specifies what kind of HTTP request is made. The contents of this request must be sent through the OutputStream returned by the getOutputStream() method of the superclass. Once an HTTP request has been sent, getResponseCode() returns the HTTP server's response code as an integer, and getResponseMessage() returns the server's response message. The disconnect() method closes the connection, and the static setFollowRedirects() specifies whether URL connections that use the HTTP protocol should automatically follow redirect responses sent by HTTP servers.
In order to successfully use this class, you need to understand the details of the HTTP protocol.
public abstract classHttpURLConnectionextends URLConnection { //Protected ConstructorprotectedHttpURLConnection(URLu); //Response Code Constantspublic static final intHTTP_ACCEPTED,HTTP_BAD_GATEWAY,HTTP_BAD_METHOD; public static final intHTTP_BAD_REQUEST,HTTP_CLIENT_TIMEOUT,HTTP_CONFLICT; public static final intHTTP_CREATED,HTTP_ENTITY_TOO_LARGE,HTTP_FORBIDDEN; public static final intHTTP_GATEWAY_TIMEOUT,HTTP_GONE,HTTP_INTERNAL_ERROR; public static final intHTTP_LENGTH_REQUIRED,HTTP_MOVED_PERM,HTTP_MOVED_TEMP; public static final intHTTP_MULT_CHOICE,HTTP_NOT_ACCEPTABLE,HTTP_NOT_AUTHORITATIVE; public static final intHTTP_NOT_FOUND,HTTP_NOT_MODIFIED,HTTP_NO_CONTENT; public static final intHTTP_OK,HTTP_PARTIAL,HTTP_PAYMENT_REQUIRED; public static final intHTTP_PRECON_FAILED,HTTP_PROXY_AUTH,HTTP_REQ_TOO_LONG; public static final intHTTP_RESET,HTTP_SEE_OTHER,HTTP_SERVER_ERROR; public static final intHTTP_UNAUTHORIZED,HTTP_UNAVAILABLE,HTTP_UNSUPPORTED_TYPE; public static final intHTTP_USE_PROXY,HTTP_VERSION; //Protected Instance Variablesprotected Stringmethod; protected intresponseCode; protected StringresponseMessage; //Class Methodspublic static booleangetFollowRedirects(); public static voidsetFollowRedirects(booleanset); //Public Instance Methodspublic abstract voiddisconnect(); public StringgetRequestMethod(); public intgetResponseCode() throws IOException; public StringgetResponseMessage() throws IOException; public voidsetRequestMethod(Stringmethod) throws ProtocolException; public abstract booleanusingProxy(); }
Hierarchy:
Object->URLConnection->HttpURLConnection