Save This Page
Home » apache-harmony-6.0-src-r917296-snapshot » java » net » [javadoc | source]
java.net
abstract public class: HttpURLConnection [javadoc | source]
java.lang.Object
   java.net.URLConnection
      java.net.HttpURLConnection

Direct Known Subclasses:
    HttpsURLConnection

This abstract subclass of {@code URLConnection} defines methods for managing HTTP connection according to the description given by RFC 2068.
Field Summary
protected  String method    The HTTP request method of this {@code HttpURLConnection}. The default value is {@code "GET"}. 
protected  int responseCode    The status code of the response obtained from the HTTP request. The default value is {@code -1}.

  • 1xx: Informational
  • 2xx: Success
  • 3xx: Relocation/Redirection
  • 4xx: Client Error
  • 5xx: Server Error
  •  
    protected  String responseMessage    The HTTP response message which corresponds to the response code. 
    protected  boolean instanceFollowRedirects    Flag to define whether the protocol will automatically follow redirects or not. The default value is {@code true}. 
    protected  int chunkLength    If the HTTP chunked encoding is enabled this parameter defines the chunk-length. Default value is {@code -1} that means the chunked encoding mode is disabled. 
    protected  int fixedContentLength    If using HTTP fixed-length streaming mode this parameter defines the fixed length of content. Default value is {@code -1} that means the fixed-length streaming mode is disabled. 
    public static final  int HTTP_ACCEPTED    Numeric status code, 202: Accepted 
    public static final  int HTTP_BAD_GATEWAY    Numeric status code, 502: Bad Gateway 
    public static final  int HTTP_BAD_METHOD    Numeric status code, 405: Bad Method 
    public static final  int HTTP_BAD_REQUEST    Numeric status code, 400: Bad Request 
    public static final  int HTTP_CLIENT_TIMEOUT    Numeric status code, 408: Client Timeout 
    public static final  int HTTP_CONFLICT    Numeric status code, 409: Conflict 
    public static final  int HTTP_CREATED    Numeric status code, 201: Created 
    public static final  int HTTP_ENTITY_TOO_LARGE    Numeric status code, 413: Entity too large 
    public static final  int HTTP_FORBIDDEN    Numeric status code, 403: Forbidden 
    public static final  int HTTP_GATEWAY_TIMEOUT    Numeric status code, 504: Gateway timeout 
    public static final  int HTTP_GONE    Numeric status code, 410: Gone 
    public static final  int HTTP_INTERNAL_ERROR    Numeric status code, 500: Internal error 
    public static final  int HTTP_LENGTH_REQUIRED    Numeric status code, 411: Length required 
    public static final  int HTTP_MOVED_PERM    Numeric status code, 301 Moved permanently 
    public static final  int HTTP_MOVED_TEMP    Numeric status code, 302: Moved temporarily 
    public static final  int HTTP_MULT_CHOICE    Numeric status code, 300: Multiple choices 
    public static final  int HTTP_NO_CONTENT    Numeric status code, 204: No content 
    public static final  int HTTP_NOT_ACCEPTABLE    Numeric status code, 406: Not acceptable 
    public static final  int HTTP_NOT_AUTHORITATIVE    Numeric status code, 203: Not authoritative 
    public static final  int HTTP_NOT_FOUND    Numeric status code, 404: Not found 
    public static final  int HTTP_NOT_IMPLEMENTED    Numeric status code, 501: Not implemented 
    public static final  int HTTP_NOT_MODIFIED    Numeric status code, 304: Not modified 
    public static final  int HTTP_OK    Numeric status code, 200: OK 
    public static final  int HTTP_PARTIAL    Numeric status code, 206: Partial 
    public static final  int HTTP_PAYMENT_REQUIRED    Numeric status code, 402: Payment required 
    public static final  int HTTP_PRECON_FAILED    Numeric status code, 412: Precondition failed 
    public static final  int HTTP_PROXY_AUTH    Numeric status code, 407: Proxy authentication required 
    public static final  int HTTP_REQ_TOO_LONG    Numeric status code, 414: Request too long 
    public static final  int HTTP_RESET    Numeric status code, 205: Reset 
    public static final  int HTTP_SEE_OTHER    Numeric status code, 303: See other 
    public static final  int HTTP_SERVER_ERROR    Numeric status code, 500: Internal error
       
      public static final  int HTTP_USE_PROXY    Numeric status code, 305: Use proxy 
      public static final  int HTTP_UNAUTHORIZED    Numeric status code, 401: Unauthorized 
      public static final  int HTTP_UNSUPPORTED_TYPE    Numeric status code, 415: Unsupported type 
      public static final  int HTTP_UNAVAILABLE    Numeric status code, 503: Unavailable 
      public static final  int HTTP_VERSION    Numeric status code, 505: Version not supported 
      Fields inherited from java.net.URLConnection:
      url,  defaultHandler,  ifModifiedSince,  useCaches,  connected,  doOutput,  doInput,  allowUserInteraction,  contentHandlers
      Constructor:
       protected HttpURLConnection(URL url) 
        Constructs a new {@code HttpURLConnection} instance pointing to the resource specified by the {@code url}.
      Method from java.net.HttpURLConnection Summary:
      disconnect,   getErrorStream,   getFollowRedirects,   getHeaderFieldDate,   getInstanceFollowRedirects,   getPermission,   getRequestMethod,   getResponseCode,   getResponseMessage,   setChunkedStreamingMode,   setFixedLengthStreamingMode,   setFollowRedirects,   setInstanceFollowRedirects,   setRequestMethod,   usingProxy
      Methods from java.net.URLConnection:
      addRequestProperty,   connect,   getAllowUserInteraction,   getConnectTimeout,   getContent,   getContent,   getContentEncoding,   getContentLength,   getContentType,   getDate,   getDefaultAllowUserInteraction,   getDefaultRequestProperty,   getDefaultUseCaches,   getDoInput,   getDoOutput,   getExpiration,   getFileNameMap,   getHeaderField,   getHeaderField,   getHeaderFieldDate,   getHeaderFieldInt,   getHeaderFieldKey,   getHeaderFields,   getIfModifiedSince,   getInputStream,   getLastModified,   getOutputStream,   getPermission,   getReadTimeout,   getRequestProperties,   getRequestProperty,   getURL,   getUseCaches,   guessContentTypeFromName,   guessContentTypeFromStream,   setAllowUserInteraction,   setConnectTimeout,   setContentHandlerFactory,   setDefaultAllowUserInteraction,   setDefaultRequestProperty,   setDefaultUseCaches,   setDoInput,   setDoOutput,   setFileNameMap,   setIfModifiedSince,   setReadTimeout,   setRequestProperty,   setUseCaches,   toString
      Methods from java.lang.Object:
      clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
      Method from java.net.HttpURLConnection Detail:
       abstract public  void disconnect()
        Closes the connection to the HTTP server.
       public InputStream getErrorStream() 
        Returns an input stream from the server in the case of an error such as the requested file has not been found on the remote server. This stream can be used to read the data the server will send back.
       public static boolean getFollowRedirects() 
        Returns the value of {@code followRedirects} which indicates if this connection follows a different URL redirected by the server. It is enabled by default.
       public long getHeaderFieldDate(String field,
          long defaultValue) 
        Returns the date value in milliseconds since {@code 01.01.1970, 00:00h} corresponding to the header field {@code field}. The {@code defaultValue} will be returned if no such field can be found in the response header.
       public boolean getInstanceFollowRedirects() 
        Returns whether this connection follows redirects.
       public Permission getPermission() throws IOException 
        Returns the permission object (in this case {@code SocketPermission}) with the host and the port number as the target name and {@code "resolve, connect"} as the action list. If the port number of this URL instance is lower than {@code 0} the port will be set to {@code 80}.
       public String getRequestMethod() 
        Returns the request method which will be used to make the request to the remote HTTP server. All possible methods of this HTTP implementation is listed in the class definition.
       public int getResponseCode() throws IOException 
        Returns the response code returned by the remote HTTP server.
       public String getResponseMessage() throws IOException 
        Returns the response message returned by the remote HTTP server.
       public  void setChunkedStreamingMode(int chunklen) 
        If the length of a HTTP request body is NOT known ahead, enable chunked transfer encoding to enable streaming with buffering. Notice that not all http servers support this mode. Sets after connection will cause an exception.
       public  void setFixedLengthStreamingMode(int contentLength) 
        If the length of a HTTP request body is known ahead, sets fixed length to enable streaming without buffering. Sets after connection will cause an exception.
       public static  void setFollowRedirects(boolean auto) 
        Sets the flag of whether this connection will follow redirects returned by the remote server. This method can only be called with the permission from the security manager.
       public  void setInstanceFollowRedirects(boolean followRedirects) 
        Sets whether this connection follows redirects.
       public  void setRequestMethod(String method) throws ProtocolException 
        Sets the request command which will be sent to the remote HTTP server. This method can only be called before the connection is made.
       abstract public boolean usingProxy()
        Returns whether this connection uses a proxy server or not.