Direct Known Subclasses:
HttpsURLConnection

  • Field Summary

    Fields

    protected int

    The chunk-length when using chunked encoding streaming mode for output.

    protected int

    The fixed content-length when using fixed-length streaming mode.

    protected long

    The fixed content-length when using fixed-length streaming mode.

    static final int

    HTTP Status-Code 202: Accepted.

    static final int

    HTTP Status-Code 502: Bad Gateway.

    static final int

    HTTP Status-Code 405: Method Not Allowed.

    static final int

    HTTP Status-Code 400: Bad Request.

    static final int

    HTTP Status-Code 408: Request Time-Out.

    static final int

    HTTP Status-Code 409: Conflict.

    static final int

    HTTP Status-Code 201: Created.

    static final int

    HTTP Status-Code 413: Request Entity Too Large.

    static final int

    HTTP Status-Code 403: Forbidden.

    static final int

    HTTP Status-Code 504: Gateway Timeout.

    static final int

    HTTP Status-Code 410: Gone.

    static final int

    HTTP Status-Code 500: Internal Server Error.

    static final int

    HTTP Status-Code 411: Length Required.

    static final int

    HTTP Status-Code 301: Moved Permanently.

    static final int

    HTTP Status-Code 302: Temporary Redirect.

    static final int

    HTTP Status-Code 300: Multiple Choices.

    static final int

    HTTP Status-Code 204: No Content.

    static final int

    HTTP Status-Code 406: Not Acceptable.

    static final int

    HTTP Status-Code 203: Non-Authoritative Information.

    static final int

    HTTP Status-Code 404: Not Found.

    static final int

    HTTP Status-Code 501: Not Implemented.

    static final int

    HTTP Status-Code 304: Not Modified.

    static final int

    HTTP Status-Code 200: OK.

    static final int

    HTTP Status-Code 206: Partial Content.

    static final int

    HTTP Status-Code 402: Payment Required.

    static final int

    HTTP Status-Code 412: Precondition Failed.

    static final int

    HTTP Status-Code 407: Proxy Authentication Required.

    static final int

    HTTP Status-Code 414: Request-URI Too Large.

    static final int

    HTTP Status-Code 205: Reset Content.

    static final int

    HTTP Status-Code 303: See Other.

    static final int

    static final int

    HTTP Status-Code 401: Unauthorized.

    static final int

    HTTP Status-Code 503: Service Unavailable.

    static final int

    HTTP Status-Code 415: Unsupported Media Type.

    static final int

    HTTP Status-Code 305: Use Proxy.

    static final int

    HTTP Status-Code 505: HTTP Version Not Supported.

    protected boolean

    If true, the protocol will automatically follow redirects.

    The HTTP method (GET,POST,PUT,etc.).

    protected int

    An int representing the three digit HTTP Status-Code.

    The HTTP response message.

    Fields declared in class URLConnection

    allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches

    protected boolean

    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 boolean

    If false, this connection object has not created a communications link to the specified URL.

    protected boolean

    This variable is set by the setDoInput method.

    protected boolean

    This variable is set by the setDoOutput method.

    protected long

    Some protocols support skipping the fetching of the object unless the object has been modified more recently than a certain time.

    protected URL

    The URL represents the remote object on the World Wide Web to which this connection is opened.

    protected boolean

    If true, the protocol is allowed to use caching whenever it can.

  • Constructor Summary

    Constructors

    protected

    Constructor for the HttpURLConnection.

  • Method Summary

    abstract void

    Indicates that other requests to the server are unlikely in the near future.

    Returns the error stream if the connection failed but the server sent useful data nonetheless.

    static boolean

    Returns a boolean indicating whether or not HTTP redirects (3xx) should be automatically followed.

    getHeaderField(int n)

    Returns the value for the nth header field.

    getHeaderFieldKey(int n)

    Returns the key for the nth header field.

    boolean

    Returns the value of this HttpURLConnection's instanceFollowRedirects field.

    Deprecated, for removal: This API element is subject to removal in a future version.

    int

    Gets the status code from an HTTP response message.

    Gets the HTTP response message, if any, returned along with the response code from a server.

    void

    Supplies an Authenticator to be used when authentication is requested through the HTTP protocol for this HttpURLConnection.

    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.

    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.

    void

    setFixedLengthStreamingMode(long contentLength)

    This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.

    static void

    setFollowRedirects(boolean set)

    Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this class.

    void

    setInstanceFollowRedirects(boolean followRedirects)

    Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this HttpURLConnection instance.

    void

    Set the method for the URL request, one of: GET POST HEAD OPTIONS PUT DELETE TRACE are legal, subject to protocol restrictions.

    abstract boolean

    Indicates if the connection is going through a proxy.

    Methods declared in class URLConnection

    addRequestProperty, connect, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getInputStream, getLastModified, getOutputStream, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString

    void

    Adds a general request property specified by a key-value pair.

    abstract void

    Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.

    boolean

    Returns the value of the allowUserInteraction field for this object.

    int

    Returns setting for connect timeout.

    Retrieves the contents of this URL connection.

    Retrieves the contents of this URL connection.

    Returns the value of the content-encoding header field.

    int

    Returns the value of the content-length header field.

    long

    Returns the value of the content-length header field as a long.

    Returns the value of the content-type header field.

    long

    Returns the value of the date header field.

    static boolean

    Returns the default value of the allowUserInteraction field.

    boolean

    Returns the default value of a URLConnection's useCaches flag.

    static boolean

    Returns the default value of the useCaches flag for the given protocol.

    boolean

    Returns the value of this URLConnection's doInput flag.

    boolean

    Returns the value of this URLConnection's doOutput flag.

    long

    Returns the value of the expires header field.

    Loads filename map (a mimetable) from a data file.

    Returns the value of the named header field.

    long

    Returns the value of the named field parsed as date.

    int

    Returns the value of the named field parsed as a number.

    long

    Returns the value of the named field parsed as a number.

    Returns an unmodifiable Map of the header fields.

    long

    Returns the value of this object's ifModifiedSince field.

    Returns an input stream that reads from this open connection.

    long

    Returns the value of the last-modified header field.

    Returns an output stream that writes to this connection.

    int

    Returns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).

    Returns an unmodifiable Map of general request properties for this connection.

    Returns the value of the named general request property for this connection.

    Returns the value of this URLConnection's URL field.

    boolean

    Returns the value of this URLConnection's useCaches field.

    Tries to determine the content type of an object, based on the specified "file" component of a URL.

    Tries to determine the type of an input stream based on the characters at the beginning of the input stream.

    void

    Set the value of the allowUserInteraction field of this URLConnection.

    void

    Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.

    static void

    Sets the ContentHandlerFactory of an application.

    static void

    Sets the default value of the allowUserInteraction field for all future URLConnection objects to the specified value.

    static void

    void

    Sets the default value of the useCaches field to the specified value.

    static void

    Sets the default value of the useCaches field for the named protocol to the given value.

    void

    Sets the value of the doInput field for this URLConnection to the specified value.

    void

    Sets the value of the doOutput field for this URLConnection to the specified value.

    static void

    void

    Sets the value of the ifModifiedSince field of this URLConnection to the specified value.

    void

    Sets the read timeout to a specified timeout, in milliseconds.

    void

    Sets the general request property.

    void

    Sets the value of the useCaches field of this URLConnection to the specified value.

    Returns a String representation of this URL connection.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Creates and returns a copy of this object.

    boolean

    Indicates whether some other object is "equal to" this one.

    protected void

    Deprecated, for removal: This API element is subject to removal in a future version.

    Returns the runtime class of this Object.

    int

    Returns a hash code value for this object.

    final void

    Wakes up a single thread that is waiting on this object's monitor.

    final void

    Wakes up all threads that are waiting on this object's monitor.

    final void

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

    final void

    wait(long timeoutMillis)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

    final void

    wait(long timeoutMillis, int nanos)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

  • Field Details

    • method

    • chunkLength

    • fixedContentLength

    • fixedContentLengthLong

    • responseCode

    • responseMessage

    • instanceFollowRedirects

    • HTTP_OK

    • HTTP_CREATED

    • HTTP_ACCEPTED

    • HTTP_NOT_AUTHORITATIVE

    • HTTP_NO_CONTENT

    • HTTP_RESET

    • HTTP_PARTIAL

    • HTTP_MULT_CHOICE

    • HTTP_MOVED_PERM

    • HTTP_MOVED_TEMP

    • HTTP_SEE_OTHER

    • HTTP_NOT_MODIFIED

    • HTTP_USE_PROXY

    • HTTP_BAD_REQUEST

    • HTTP_UNAUTHORIZED

    • HTTP_PAYMENT_REQUIRED

    • HTTP_FORBIDDEN

    • HTTP_NOT_FOUND

    • HTTP_BAD_METHOD

    • HTTP_NOT_ACCEPTABLE

    • HTTP_PROXY_AUTH

    • HTTP_CLIENT_TIMEOUT

    • HTTP_CONFLICT

    • HTTP_GONE

    • HTTP_LENGTH_REQUIRED

    • HTTP_PRECON_FAILED

    • HTTP_ENTITY_TOO_LARGE

    • HTTP_REQ_TOO_LONG

    • HTTP_UNSUPPORTED_TYPE

    • HTTP_SERVER_ERROR

    • HTTP_INTERNAL_ERROR

    • HTTP_NOT_IMPLEMENTED

    • HTTP_BAD_GATEWAY

    • HTTP_UNAVAILABLE

    • HTTP_GATEWAY_TIMEOUT

    • HTTP_VERSION

  • Constructor Details

    • HttpURLConnection

  • Method Details

    • setAuthenticator

    • setFixedLengthStreamingMode

    • setFixedLengthStreamingMode

    • setChunkedStreamingMode

    • setFollowRedirects

    • getFollowRedirects

    • setInstanceFollowRedirects

    • getInstanceFollowRedirects

    • setRequestMethod

    • getRequestMethod

    • getResponseCode

    • getResponseMessage

    • disconnect

    • usingProxy

    • getPermission

    • getErrorStream