HttpURLConnection


HttpURLConnection java.net

Java 1.1

This class is a specialization of URLConnection . An instance of this class is returned when the openConnection( ) method is called for a URL object that uses the HTTP protocol. The many constants defined by this class are the status codes returned by HTTP servers. setRequestMethod( ) specifies what kind of HTTP request is made. The contents of this request must be sent through the OutputStream returned by the getOutputStream( ) method of the superclass. Once an HTTP request has been sent, getresponseCode( ) returns the HTTP server's response code as an integer, and geTResponseMessage( ) returns the server's response message. The disconnect( ) method closes the connection. The static setFollowRedirects( ) specifies whether URL connections that use the HTTP protocol should automatically follow redirect responses sent by HTTP servers. In order to successfully use this class, you need to understand the details of the HTTP protocol.

Figure 12-5. java.net.HttpURLConnection

 public abstract class  HttpURLConnection  extends URLConnection {  // Protected Constructors  protected  HttpURLConnection  (URL  u  );  // Public Constants  public static final int  HTTP_ACCEPTED  ;  =202  public static final int  HTTP_BAD_GATEWAY  ;  =502  public static final int  HTTP_BAD_METHOD  ;  =405  public static final int  HTTP_BAD_REQUEST  ;  =400  public static final int  HTTP_CLIENT_TIMEOUT  ;  =408  public static final int  HTTP_CONFLICT  ;  =409  public static final int  HTTP_CREATED  ;  =201  public static final int  HTTP_ENTITY_TOO_LARGE  ;  =413  public static final int  HTTP_FORBIDDEN  ;  =403  public static final int  HTTP_GATEWAY_TIMEOUT  ;  =504  public static final int  HTTP_GONE  ;  =410  public static final int  HTTP_INTERNAL_ERROR  ;  =500  public static final int  HTTP_LENGTH_REQUIRED  ;  =411  public static final int  HTTP_MOVED_PERM  ;  =301  public static final int  HTTP_MOVED_TEMP  ;  =302  public static final int  HTTP_MULT_CHOICE  ;  =300  public static final int  HTTP_NO_CONTENT  ;  =204  public static final int  HTTP_NOT_ACCEPTABLE  ;  =406  public static final int  HTTP_NOT_AUTHORITATIVE  ;  =203  public static final int  HTTP_NOT_FOUND  ;  =404   1.3  public static final int  HTTP_NOT_IMPLEMENTED  ;  =501  public static final int  HTTP_NOT_MODIFIED  ;  =304  public static final int  HTTP_OK  ;  =200  public static final int  HTTP_PARTIAL  ;  =206  public static final int  HTTP_PAYMENT_REQUIRED  ;  =402  public static final int  HTTP_PRECON_FAILED  ;  =412  public static final int  HTTP_PROXY_AUTH  ;  =407  public static final int  HTTP_REQ_TOO_LONG  ;  =414  public static final int  HTTP_RESET  ;  =205  public static final int  HTTP_SEE_OTHER  ;  =303  public static final int  HTTP_UNAUTHORIZED  ;  =401  public static final int  HTTP_UNAVAILABLE  ;  =503  public static final int  HTTP_UNSUPPORTED_TYPE  ;  =415  public static final int  HTTP_USE_PROXY  ;  =305  public static final int  HTTP_VERSION  ;  =505   // Public Class Methods  public static boolean  getFollowRedirects  ( );      public static void  setFollowRedirects  (boolean  set  );  // Public Instance Methods  public abstract void  disconnect  ( );  1.2  public java.io.InputStream  getErrorStream  ( );  constant   1.3  public boolean  getInstanceFollowRedirects  ( );        public String  getRequestMethod  ( );        public int  getResponseCode  ( ) throws java.io.IOException;        public String  getResponseMessage  ( ) throws java.io.IOException;  5.0  public void  setChunkedStreamingMode  (int  chunklen  );  5.0  public void  setFixedLengthStreamingMode  (int  contentLength  );  1.3  public void  setInstanceFollowRedirects  (boolean  followRedirects  );        public void  setRequestMethod  (String  method  ) throws ProtocolException;        public abstract boolean  usingProxy  ( );  // Public Methods Overriding URLConnection   1.4  public String  getHeaderField  (int  n  );  constant   1.3  public long  getHeaderFieldDate  (String  name  , long  Default  );  1.4  public String  getHeaderFieldKey  (int  n  );  constant   1.2  public java.security.Permission  getPermission  ( )  throws java.io.IOException;  // Protected Instance Fields   5.0  protected int  chunkLength  ;  5.0  protected int  fixedContentLength  ;  1.3  protected boolean  instanceFollowRedirects  ;        protected String  method  ;        protected int  responseCode  ;        protected String  responseMessage  ;  // Deprecated Public Fields   #  public static final int  HTTP_SERVER_ERROR  ;  =500  } 

Subclasses

javax.net.ssl.HttpsURLConnection



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net