    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class java.net.HttpURLConnection

    java.lang.Object
       |
       +----java.net.URLConnection
               |
               +----java.net.HttpURLConnection

public class HttpURLConnection
extends URLConnection

A URLConnection with support for HTTP-specific features. See the spec for details.

##

HTTP_ACCEPTED
HTTP_BAD_GATEWAY
HTTP_BAD_METHOD
HTTP_BAD_REQUEST
  4XX: client error
HTTP_CLIENT_TIMEOUT
HTTP_CONFLICT
HTTP_CREATED
HTTP_ENTITY_TOO_LARGE
HTTP_FORBIDDEN
HTTP_GATEWAY_TIMEOUT
HTTP_GONE
HTTP_INTERNAL_ERROR
HTTP_LENGTH_REQUIRED
HTTP_MOVED_PERM
HTTP_MOVED_TEMP
HTTP_MULT_CHOICE
  3XX: relocation/redirect
HTTP_NO_CONTENT
HTTP_NOT_ACCEPTABLE
HTTP_NOT_AUTHORITATIVE
HTTP_NOT_FOUND
HTTP_NOT_MODIFIED
HTTP_OK
  2XX: generally "OK"
HTTP_PARTIAL
HTTP_PAYMENT_REQUIRED
HTTP_PRECON_FAILED
HTTP_PROXY_AUTH
HTTP_REQ_TOO_LONG
HTTP_RESET
HTTP_SEE_OTHER
HTTP_SERVER_ERROR
  5XX: server error
HTTP_UNAUTHORIZED
HTTP_UNAVAILABLE
HTTP_UNSUPPORTED_TYPE
HTTP_USE_PROXY
HTTP_VERSION
method
responseCode
responseMessage

##

HttpURLConnection(URL)

##

disconnect()
  Close the connection to the server
getFollowRedirects()
getRequestMethod()
  get the request method
getResponseCode()
  Gets HTTP response status.
getResponseMessage()
  Gets the HTTP response message, if any, returned along with the response code from a server.
setFollowRedirects(boolean)
  Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this class.
setRequestMethod(String)
  Set the method for the URL request, one of:
  - GET
  - POST
  - HEAD
  - OPTIONS
  - PUT
  - DELETE
  - TRACE
  are legal, subject to protocol restrictions.
usingProxy()
  Indicates if the connection is going through a proxy

##

method

      protected String method

responseCode

      protected int responseCode

responseMessage

      protected String responseMessage

HTTP_OK

      public final static int HTTP_OK

  2XX: generally "OK"

HTTP_CREATED

      public final static int HTTP_CREATED

HTTP_ACCEPTED

      public final static int HTTP_ACCEPTED

HTTP_NOT_AUTHORITATIVE

      public final static int HTTP_NOT_AUTHORITATIVE

HTTP_NO_CONTENT

      public final static int HTTP_NO_CONTENT

HTTP_RESET

      public final static int HTTP_RESET

HTTP_PARTIAL

      public final static int HTTP_PARTIAL

HTTP_MULT_CHOICE

      public final static int HTTP_MULT_CHOICE

  3XX: relocation/redirect

HTTP_MOVED_PERM

      public final static int HTTP_MOVED_PERM

HTTP_MOVED_TEMP

      public final static int HTTP_MOVED_TEMP

HTTP_SEE_OTHER

      public final static int HTTP_SEE_OTHER

HTTP_NOT_MODIFIED

      public final static int HTTP_NOT_MODIFIED

HTTP_USE_PROXY

      public final static int HTTP_USE_PROXY

HTTP_BAD_REQUEST

      public final static int HTTP_BAD_REQUEST

  4XX: client error

HTTP_UNAUTHORIZED

      public final static int HTTP_UNAUTHORIZED

HTTP_PAYMENT_REQUIRED

      public final static int HTTP_PAYMENT_REQUIRED

HTTP_FORBIDDEN

      public final static int HTTP_FORBIDDEN

HTTP_NOT_FOUND

      public final static int HTTP_NOT_FOUND

HTTP_BAD_METHOD

      public final static int HTTP_BAD_METHOD

HTTP_NOT_ACCEPTABLE

      public final static int HTTP_NOT_ACCEPTABLE

HTTP_PROXY_AUTH

      public final static int HTTP_PROXY_AUTH

HTTP_CLIENT_TIMEOUT

      public final static int HTTP_CLIENT_TIMEOUT

HTTP_CONFLICT

      public final static int HTTP_CONFLICT

HTTP_GONE

      public final static int HTTP_GONE

HTTP_LENGTH_REQUIRED

      public final static int HTTP_LENGTH_REQUIRED

HTTP_PRECON_FAILED

      public final static int HTTP_PRECON_FAILED

HTTP_ENTITY_TOO_LARGE

      public final static int HTTP_ENTITY_TOO_LARGE

HTTP_REQ_TOO_LONG

      public final static int HTTP_REQ_TOO_LONG

HTTP_UNSUPPORTED_TYPE

      public final static int HTTP_UNSUPPORTED_TYPE

HTTP_SERVER_ERROR

      public final static int HTTP_SERVER_ERROR

  5XX: server error

HTTP_INTERNAL_ERROR

      public final static int HTTP_INTERNAL_ERROR

HTTP_BAD_GATEWAY

      public final static int HTTP_BAD_GATEWAY

HTTP_UNAVAILABLE

      public final static int HTTP_UNAVAILABLE

HTTP_GATEWAY_TIMEOUT

      public final static int HTTP_GATEWAY_TIMEOUT

HTTP_VERSION

      public final static int HTTP_VERSION

##

HttpURLConnection

      protected HttpURLConnection(URL u)

##

setFollowRedirects

      public static void setFollowRedirects(boolean set)

  Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this class. False by default. Applets cannot change this variable.

getFollowRedirects

      public static boolean getFollowRedirects()

setRequestMethod

      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. The default method is GET.

getRequestMethod

      public String getRequestMethod()

  get the request method

getResponseCode

      public int getResponseCode() throws IOException

  Gets HTTP response status. From responses like:

       HTTP/1.0 200 OK
       HTTP/1.0 401 Unauthorized

  Extracts the ints 200 and 401 respectively. Returns -1 if none can be discerned from the response (i.e., the response is not valid HTTP).

getResponseMessage

      public String getResponseMessage() throws IOException

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

       HTTP/1.0 200 OK
       HTTP/1.0 404 Not Found

  Extracts the Strings "OK" and "Not Found" respectively. Returns null if none could be discerned from the responses (the result was not valid HTTP).

disconnect

      public abstract void disconnect()

  Close the connection to the server

usingProxy

      public abstract boolean usingProxy()

  Indicates if the connection is going through a proxy

    All Packages  Class Hierarchy  This Package  Previous  Next  Index