Java java.net HttpURLConnection fields, constructors, methods, implement or subclass

Example usage for Java java.net HttpURLConnection fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.net HttpURLConnection.

The text is from its open source code.

Subclass

java.net.HttpURLConnection has subclasses.
Click this link to see all its subclasses.

Field

intHTTP_OK
HTTP Status-Code 200: OK.
intHTTP_CREATED
HTTP Status-Code 201: Created.
intHTTP_ACCEPTED
HTTP Status-Code 202: Accepted.
intHTTP_NOT_AUTHORITATIVE
HTTP Status-Code 203: Non-Authoritative Information.
intHTTP_NO_CONTENT
HTTP Status-Code 204: No Content.
intHTTP_RESET
HTTP Status-Code 205: Reset Content.
intHTTP_PARTIAL
HTTP Status-Code 206: Partial Content.
intHTTP_MULT_CHOICE
HTTP Status-Code 300: Multiple Choices.
intHTTP_MOVED_PERM
HTTP Status-Code 301: Moved Permanently.
intHTTP_MOVED_TEMP
HTTP Status-Code 302: Temporary Redirect.
intHTTP_SEE_OTHER
HTTP Status-Code 303: See Other.
intHTTP_NOT_MODIFIED
HTTP Status-Code 304: Not Modified.
intHTTP_BAD_REQUEST
HTTP Status-Code 400: Bad Request.
intHTTP_UNAUTHORIZED
HTTP Status-Code 401: Unauthorized.
intHTTP_PAYMENT_REQUIRED
HTTP Status-Code 402: Payment Required.
intHTTP_FORBIDDEN
HTTP Status-Code 403: Forbidden.
intHTTP_NOT_FOUND
HTTP Status-Code 404: Not Found.
intHTTP_BAD_METHOD
HTTP Status-Code 405: Method Not Allowed.
intHTTP_NOT_ACCEPTABLE
HTTP Status-Code 406: Not Acceptable.
intHTTP_PROXY_AUTH
HTTP Status-Code 407: Proxy Authentication Required.
intHTTP_CLIENT_TIMEOUT
HTTP Status-Code 408: Request Time-Out.
intHTTP_CONFLICT
HTTP Status-Code 409: Conflict.
intHTTP_GONE
HTTP Status-Code 410: Gone.
intHTTP_PRECON_FAILED
HTTP Status-Code 412: Precondition Failed.
intHTTP_ENTITY_TOO_LARGE
HTTP Status-Code 413: Request Entity Too Large.
intHTTP_REQ_TOO_LONG
HTTP Status-Code 414: Request-URI Too Large.
intHTTP_UNSUPPORTED_TYPE
HTTP Status-Code 415: Unsupported Media Type.
intHTTP_INTERNAL_ERROR
HTTP Status-Code 500: Internal Server Error.
intHTTP_NOT_IMPLEMENTED
HTTP Status-Code 501: Not Implemented.
intHTTP_BAD_GATEWAY
HTTP Status-Code 502: Bad Gateway.
intHTTP_UNAVAILABLE
HTTP Status-Code 503: Service Unavailable.
intHTTP_GATEWAY_TIMEOUT
HTTP Status-Code 504: Gateway Timeout.
intHTTP_VERSION
HTTP Status-Code 505: HTTP Version Not Supported.

Method

voidaddRequestProperty(String key, String value)
Adds a general request property specified by a key-value pair.
voidconnect()
Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
voiddisconnect()
Indicates that other requests to the server are unlikely in the near future.
booleangetAllowUserInteraction()
Returns the value of the allowUserInteraction field for this object.
ClassgetClass()
Returns the runtime class of this Object .
intgetConnectTimeout()
Returns setting for connect timeout.
ObjectgetContent()
Retrieves the contents of this URL connection.
StringgetContentEncoding()
Returns the value of the content-encoding header field.
intgetContentLength()
Returns the value of the content-length header field.
longgetContentLengthLong()
Returns the value of the content-length header field as a long.
StringgetContentType()
Returns the value of the content-type header field.
longgetDate()
Returns the value of the date header field.
booleangetDoOutput()
Returns the value of this URLConnection 's doOutput flag.
InputStreamgetErrorStream()
Returns the error stream if the connection failed but the server sent useful data nonetheless.
longgetExpiration()
Returns the value of the expires header field.
booleangetFollowRedirects()
Returns a boolean indicating whether or not HTTP redirects (3xx) should be automatically followed.
StringgetHeaderField(int n)
Returns the value for the n th header field.
longgetHeaderFieldDate(String name, long Default)
intgetHeaderFieldInt(String name, int Default)
Returns the value of the named field parsed as a number.
StringgetHeaderFieldKey(int n)
Returns the key for the n th header field.
longgetHeaderFieldLong(String name, long Default)
Returns the value of the named field parsed as a number.
Map>getHeaderFields()
Returns an unmodifiable Map of the header fields.
longgetIfModifiedSince()
Returns the value of this object's ifModifiedSince field.
InputStreamgetInputStream()
Returns an input stream that reads from this open connection.
longgetLastModified()
Returns the value of the last-modified header field.
OutputStreamgetOutputStream()
Returns an output stream that writes to this connection.
intgetReadTimeout()
Returns setting for read timeout.
StringgetRequestMethod()
Get the request method.
Map>getRequestProperties()
Returns an unmodifiable Map of general request properties for this connection.
StringgetRequestProperty(String key)
Returns the value of the named general request property for this connection.
intgetResponseCode()
Gets the status code from an HTTP response message.
StringgetResponseMessage()
Gets the HTTP response message, if any, returned along with the response code from a server.
URLgetURL()
Returns the value of this URLConnection 's URL field.
voidsetAllowUserInteraction(boolean allowuserinteraction)
Set the value of the allowUserInteraction field of this URLConnection .
voidsetChunkedStreamingMode(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.
voidsetConnectTimeout(int timeout)
Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.
voidsetDefaultUseCaches(boolean defaultusecaches)
Sets the default value of the useCaches field to the specified value.
voidsetDoInput(boolean doinput)
Sets the value of the doInput field for this URLConnection to the specified value.
voidsetDoOutput(boolean dooutput)
Sets the value of the doOutput field for this URLConnection to the specified value.
voidsetFixedLengthStreamingMode(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.
voidsetFixedLengthStreamingMode(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.
voidsetFollowRedirects(boolean set)
Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this class.
voidsetIfModifiedSince(long ifmodifiedsince)
Sets the value of the ifModifiedSince field of this URLConnection to the specified value.
voidsetInstanceFollowRedirects(boolean followRedirects)
Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this HttpURLConnection instance.
voidsetReadTimeout(int timeout)
Sets the read timeout to a specified timeout, in milliseconds.
voidsetRequestMethod(String method)
Set the method for the URL request, one of:
  • GET
  • POST
  • HEAD
  • OPTIONS
  • PUT
  • DELETE
  • TRACE
are legal, subject to protocol restrictions.
voidsetRequestProperty(String key, String value)
Sets the general request property.
voidsetUseCaches(boolean usecaches)
Sets the value of the useCaches field of this URLConnection to the specified value.
StringtoString()
Returns a String representation of this URL connection.
booleanusingProxy()
Indicates if the connection is going through a proxy.