API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.net. HttpURLConnection View Source
Author(s)
Since
JDK1.1
Version
Serial
Hierarchy
 Object
      URLConnection
          HttpURLConnection
Implements
Subclasses
Description
publicabstract abstract class HttpURLConnection
  A URLConnection with support for HTTP-specific features.
Constructors
protected HttpURLConnection (URL u)
  Constructor for the HttpURLConnection.
Methods
Hide/Show inherited methods
public void addRequestProperty (String key, String value) [Inherited From URLConnection]
  Adds a general request property specified by a key-value pair.
publicabstract void connect () throws IOException [Inherited From URLConnection]
  Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
publicabstract void disconnect ()
  Indicates that other requests to the server are unlikely in the near future.
public boolean getAllowUserInteraction () [Inherited From URLConnection]
  Returns the value of the allowUserInteraction field for this object.
public int getConnectTimeout () [Inherited From URLConnection]
  Returns setting for connect timeout.
public Object getContent () throws IOException [Inherited From URLConnection]
  Retrieves the contents of this URL connection.
public Object getContent (Class classes) throws IOException [Inherited From URLConnection]
  Retrieves the contents of this URL connection.
public String getContentEncoding () [Inherited From URLConnection]
  Returns the value of the content-encoding header field.
pack-privatesynchronized ContentHandler getContentHandler () throws UnknownServiceException [Inherited From URLConnection]
  Gets the Content Handler appropriate for this connection.
public int getContentLength () [Inherited From URLConnection]
  Returns the value of the content-length header field.
public String getContentType () [Inherited From URLConnection]
  Returns the value of the content-type header field.
public long getDate () [Inherited From URLConnection]
  Returns the value of the date header field.
publicstatic boolean getDefaultAllowUserInteraction () [Inherited From URLConnection]
  Returns the default value of the allowUserInteraction field.
@Deprecated
publicstatic String getDefaultRequestProperty (String key) [Inherited From URLConnection]
  Returns the value of the default request property.
public boolean getDefaultUseCaches () [Inherited From URLConnection]
  Returns the default value of a URLConnection's useCaches flag.
public boolean getDoInput () [Inherited From URLConnection]
  Returns the value of this URLConnection's doInput flag.
public boolean getDoOutput () [Inherited From URLConnection]
  Returns the value of this URLConnection's doOutput flag.
public InputStream getErrorStream ()
  Returns the error stream if the connection failed but the server sent useful data nonetheless.
public long getExpiration () [Inherited From URLConnection]
  Returns the value of the expires header field.
publicstaticsynchronized FileNameMap getFileNameMap () [Inherited From URLConnection]
  Loads filename map (a mimetable) from a data file.
publicstatic boolean getFollowRedirects ()
  Returns a boolean indicating whether or not HTTP redirects (3xx) should be automatically followed.
public String getHeaderField (int n) [Overrides URLConnection]
  Returns the value for the nth header field.
public String getHeaderField (String name) [Inherited From URLConnection]
  Returns the value of the named header field.
public long getHeaderFieldDate (String name, long Default) [Overrides URLConnection]
public int getHeaderFieldInt (String name, int Default) [Inherited From URLConnection]
  Returns the value of the named field parsed as a number.
public String getHeaderFieldKey (int n) [Overrides URLConnection]
  Returns the key for the nth header field.
public Map<String, List<String>> getHeaderFields () [Inherited From URLConnection]
  Returns an unmodifiable Map of the header fields.
public long getIfModifiedSince () [Inherited From URLConnection]
  Returns the value of this object's ifModifiedSince field.
public InputStream getInputStream () throws IOException [Inherited From URLConnection]
  Returns an input stream that reads from this open connection.
public boolean getInstanceFollowRedirects ()
  Returns the value of this HttpURLConnection's instanceFollowRedirects field.
public long getLastModified () [Inherited From URLConnection]
  Returns the value of the last-modified header field.
public OutputStream getOutputStream () throws IOException [Inherited From URLConnection]
  Returns an output stream that writes to this connection.
public Permission getPermission () throws IOException [Overrides URLConnection]
public int getReadTimeout () [Inherited From URLConnection]
  Returns setting for read timeout.
public String getRequestMethod ()
  Get the request method.
public Map<String, List<String>> getRequestProperties () [Inherited From URLConnection]
  Returns an unmodifiable Map of general request properties for this connection.
public String getRequestProperty (String key) [Inherited From URLConnection]
  Returns the value of the named general request property for this connection.
public int getResponseCode () throws IOException
  Gets the status code from an HTTP response message.
public String getResponseMessage () throws IOException
  Gets the HTTP response message, if any, returned along with the response code from a server.
public URL getURL () [Inherited From URLConnection]
  Returns the value of this URLConnection's URL field.
public boolean getUseCaches () [Inherited From URLConnection]
  Returns the value of this URLConnection's useCaches field.
publicstatic String guessContentTypeFromName (String fname) [Inherited From URLConnection]
  Tries to determine the content type of an object, based on the specified "file" component of a URL.
publicstatic String guessContentTypeFromStream (InputStream is) throws IOException [Inherited From URLConnection]
  Tries to determine the type of an input stream based on the characters at the beginning of the input stream.
public void setAllowUserInteraction (boolean allowuserinteraction) [Inherited From URLConnection]
  Set the value of the allowUserInteraction field of this URLConnection.
public void setChunkedStreamingMode (int chunklen)
  This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance.
public void setConnectTimeout (int timeout) [Inherited From URLConnection]
  Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.
publicstaticsynchronized void setContentHandlerFactory (ContentHandlerFactory fac) [Inherited From URLConnection]
  Sets the ContentHandlerFactory of an application.
publicstatic void setDefaultAllowUserInteraction (boolean defaultallowuserinteraction) [Inherited From URLConnection]
  Sets the default value of the allowUserInteraction field for all future URLConnection objects to the specified value.
@Deprecated
publicstatic void setDefaultRequestProperty (String key, String value) [Inherited From URLConnection]
  Sets the default value of a general request property.
public void setDefaultUseCaches (boolean defaultusecaches) [Inherited From URLConnection]
  Sets the default value of the useCaches field to the specified value.
public void setDoInput (boolean doinput) [Inherited From URLConnection]
  Sets the value of the doInput field for this URLConnection to the specified value.
public void setDoOutput (boolean dooutput) [Inherited From URLConnection]
  Sets the value of the doOutput field for this URLConnection to the specified value.
publicstatic void setFileNameMap (FileNameMap map) [Inherited From URLConnection]
  Sets the FileNameMap.
public void setFixedLengthStreamingMode (int contentLength)
  This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.
publicstatic void setFollowRedirects (boolean set)
  Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this class.
public void setIfModifiedSince (long ifmodifiedsince) [Inherited From URLConnection]
  Sets the value of the ifModifiedSince field of this URLConnection to the specified value.
public void setInstanceFollowRedirects (boolean followRedirects)
  Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this HttpURLConnection instance.
public void setReadTimeout (int timeout) [Inherited From URLConnection]
  Sets the read timeout to a specified timeout, in milliseconds.
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, subject to protocol restrictions.
public void setRequestProperty (String key, String value) [Inherited From URLConnection]
  Sets the general request property.
public void setUseCaches (boolean usecaches) [Inherited From URLConnection]
  Sets the value of the useCaches field of this URLConnection to the specified value.
public String toString () [Inherited From URLConnection]
  Returns a String representation of this URL connection.
publicabstract boolean usingProxy ()
  Indicates if the connection is going through a proxy.
Fields
Hide/Show inherited fields
protected boolean allowUserInteraction [Inherited From URLConnection]
  If true, this URL is being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog.
protected int chunkLength
  The chunk-length when using chunked encoding streaming mode for output.
protected boolean connected [Inherited From URLConnection]
  If false, this connection object has not created a communications link to the specified URL.
protected boolean doInput [Inherited From URLConnection]
  This variable is set by the setDoInput method.
protected boolean doOutput [Inherited From URLConnection]
  This variable is set by the setDoOutput method.
pack-privatestatic ContentHandlerFactory factory [Inherited From URLConnection]
The ContentHandler factory.
protected int fixedContentLength
  The fixed content-length when using fixed-length streaming mode.
publicfinalstatic int HTTP_ACCEPTED = "202"
HTTP Status-Code 202: Accepted.
publicfinalstatic int HTTP_BAD_GATEWAY = "502"
HTTP Status-Code 502: Bad Gateway.
publicfinalstatic int HTTP_BAD_METHOD = "405"
HTTP Status-Code 405: Method Not Allowed.
publicfinalstatic int HTTP_BAD_REQUEST = "400"
HTTP Status-Code 400: Bad Request.
publicfinalstatic int HTTP_CLIENT_TIMEOUT = "408"
HTTP Status-Code 408: Request Time-Out.
publicfinalstatic int HTTP_CONFLICT = "409"
HTTP Status-Code 409: Conflict.
publicfinalstatic int HTTP_CREATED = "201"
HTTP Status-Code 201: Created.
publicfinalstatic int HTTP_ENTITY_TOO_LARGE = "413"
HTTP Status-Code 413: Request Entity Too Large.
publicfinalstatic int HTTP_FORBIDDEN = "403"
HTTP Status-Code 403: Forbidden.
publicfinalstatic int HTTP_GATEWAY_TIMEOUT = "504"
HTTP Status-Code 504: Gateway Timeout.
publicfinalstatic int HTTP_GONE = "410"
HTTP Status-Code 410: Gone.
publicfinalstatic int HTTP_INTERNAL_ERROR = "500"
HTTP Status-Code 500: Internal Server Error.
publicfinalstatic int HTTP_LENGTH_REQUIRED = "411"
HTTP Status-Code 411: Length Required.
publicfinalstatic int HTTP_MOVED_PERM = "301"
HTTP Status-Code 301: Moved Permanently.
publicfinalstatic int HTTP_MOVED_TEMP = "302"
HTTP Status-Code 302: Temporary Redirect.
publicfinalstatic int HTTP_MULT_CHOICE = "300"
HTTP Status-Code 300: Multiple Choices.
publicfinalstatic int HTTP_NO_CONTENT = "204"
HTTP Status-Code 204: No Content.
publicfinalstatic int HTTP_NOT_ACCEPTABLE = "406"
HTTP Status-Code 406: Not Acceptable.
publicfinalstatic int HTTP_NOT_AUTHORITATIVE = "203"
HTTP Status-Code 203: Non-Authoritative Information.
publicfinalstatic int HTTP_NOT_FOUND = "404"
HTTP Status-Code 404: Not Found.
publicfinalstatic int HTTP_NOT_IMPLEMENTED = "501"
HTTP Status-Code 501: Not Implemented.
publicfinalstatic int HTTP_NOT_MODIFIED = "304"
HTTP Status-Code 304: Not Modified.
publicfinalstatic int HTTP_OK = "200"
HTTP Status-Code 200: OK.
publicfinalstatic int HTTP_PARTIAL = "206"
HTTP Status-Code 206: Partial Content.
publicfinalstatic int HTTP_PAYMENT_REQUIRED = "402"
HTTP Status-Code 402: Payment Required.
publicfinalstatic int HTTP_PRECON_FAILED = "412"
HTTP Status-Code 412: Precondition Failed.
publicfinalstatic int HTTP_PROXY_AUTH = "407"
HTTP Status-Code 407: Proxy Authentication Required.
publicfinalstatic int HTTP_REQ_TOO_LONG = "414"
HTTP Status-Code 414: Request-URI Too Large.
publicfinalstatic int HTTP_RESET = "205"
HTTP Status-Code 205: Reset Content.
publicfinalstatic int HTTP_SEE_OTHER = "303"
HTTP Status-Code 303: See Other.
@Deprecated
publicfinalstatic int HTTP_SERVER_ERROR = "500"
HTTP Status-Code 500: Internal Server Error.
publicfinalstatic int HTTP_UNAUTHORIZED = "401"
HTTP Status-Code 401: Unauthorized.
publicfinalstatic int HTTP_UNAVAILABLE = "503"
HTTP Status-Code 503: Service Unavailable.
publicfinalstatic int HTTP_UNSUPPORTED_TYPE = "415"
HTTP Status-Code 415: Unsupported Media Type.
publicfinalstatic int HTTP_USE_PROXY = "305"
HTTP Status-Code 305: Use Proxy.
publicfinalstatic int HTTP_VERSION = "505"
HTTP Status-Code 505: HTTP Version Not Supported.
protected long ifModifiedSince [Inherited From URLConnection]
  Some protocols support skipping the fetching of the object unless the object has been modified more recently than a certain time.
protected boolean instanceFollowRedirects
  If true, the protocol will automatically follow redirects.
protected String method
The HTTP method (GET,POST,PUT,etc.).
protected int responseCode
  An int representing the three digit HTTP Status-Code.
protected String responseMessage
The HTTP response message.
protected URL url [Inherited From URLConnection]
  The URL represents the remote object on the World Wide Web to which this connection is opened.
protected boolean useCaches [Inherited From URLConnection]
  If true, the protocol is allowed to use caching whenever it can.
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar