public class

HttpClient

extends NetworkClient
java.lang.Object
   ↳ sun.net.NetworkClient
     ↳ sun.net.www.http.HttpClient

Summary

Fields
protected boolean cachedHttpClient
protected CookieHandler cookieHandler
protected String host
protected static KeepAliveCache kac
protected int port
protected boolean proxyDisabled This field is deprecated. No replacement.
public boolean reuse
protected URL url Url being fetched.
public boolean usingProxy
[Expand]
Inherited Fields
From class sun.net.NetworkClient
Public Constructors
HttpClient(URL url, String proxyHost, int proxyPort)
HttpClient(URL url, String proxyHost, int proxyPort, boolean proxyDisabled, int to)
Protected Constructors
HttpClient()
HttpClient(URL url, boolean proxyDisabled)
HttpClient(URL url, Proxy p, int to)
Public Methods
static HttpClient New(URL url, Proxy p, int to)
static HttpClient New(URL url)
static HttpClient New(URL url, String proxyHost, int proxyPort, boolean useCache, int to)
static HttpClient New(URL url, String proxyHost, int proxyPort, boolean useCache)
static HttpClient New(URL url, Proxy p, int to, boolean useCache)
static HttpClient New(URL url, boolean useCache)
void afterConnect()
void closeIdleConnection()
void closeServer()
Close an open connection to the server.
void finished()
boolean getHttpKeepAliveSet()
synchronized InputStream getInputStream()
OutputStream getOutputStream()
String getProxyHostUsed()
int getProxyPortUsed()
String getURLFile()
boolean isCachedConnection()
final boolean isKeepingAlive()
boolean needsTunneling()
void openServer(String server, int port)
Open a connection to the server.
boolean parseHTTP(MessageHeader responses, ProgressSource pi, HttpURLConnection httpuc)
Parse the first line of the HTTP request.
synchronized static void resetProperties()
This method is deprecated. -- system properties are no longer cached.
void setCacheRequest(CacheRequest cacheRequest)
void setDoNotRetry(boolean value)
int setTimeout(int timeout)
String toString()
Returns a string representation of the object.
void writeRequests(MessageHeader head)
This method is deprecated. No replacement.
void writeRequests(MessageHeader head, PosterOutputStream pos)
Protected Methods
void finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
int getDefaultPort()
return default port number (subclasses may override)
boolean isInKeepAliveCache()
static Proxy newHttpProxy(String proxyHost, int proxyPort, String proto)
synchronized void openServer()
synchronized void putInKeepAliveCache()
[Expand]
Inherited Methods
From class sun.net.NetworkClient
From class java.lang.Object

Fields

protected boolean cachedHttpClient

protected CookieHandler cookieHandler

protected String host

protected static KeepAliveCache kac

protected int port

protected boolean proxyDisabled

This field is deprecated.
No replacement.

public boolean reuse

protected URL url

Url being fetched.

public boolean usingProxy

Public Constructors

public HttpClient (URL url, String proxyHost, int proxyPort)

Throws
IOException

public HttpClient (URL url, String proxyHost, int proxyPort, boolean proxyDisabled, int to)

Throws
IOException

Protected Constructors

protected HttpClient ()

protected HttpClient (URL url, boolean proxyDisabled)

Throws
IOException

protected HttpClient (URL url, Proxy p, int to)

Throws
IOException

Public Methods

public static HttpClient New (URL url, Proxy p, int to)

Throws
IOException

public static HttpClient New (URL url)

Throws
IOException

public static HttpClient New (URL url, String proxyHost, int proxyPort, boolean useCache, int to)

Throws
IOException

public static HttpClient New (URL url, String proxyHost, int proxyPort, boolean useCache)

Throws
IOException

public static HttpClient New (URL url, Proxy p, int to, boolean useCache)

Throws
IOException

public static HttpClient New (URL url, boolean useCache)

Throws
IOException

public void afterConnect ()

public void closeIdleConnection ()

public void closeServer ()

Close an open connection to the server.

public void finished ()

public boolean getHttpKeepAliveSet ()

Returns
  • true iff http keep alive is set (i.e. enabled). Defaults to true if the system property http.keepAlive isn't set.

public synchronized InputStream getInputStream ()

public OutputStream getOutputStream ()

public String getProxyHostUsed ()

Returns
  • the proxy host being used for this client, or null if we're not going through a proxy

public int getProxyPortUsed ()

Returns
  • the proxy port being used for this client. Meaningless if getProxyHostUsed() gives null.

public String getURLFile ()

Throws
IOException

public boolean isCachedConnection ()

public final boolean isKeepingAlive ()

public boolean needsTunneling ()

public void openServer (String server, int port)

Open a connection to the server.

Throws
IOException

public boolean parseHTTP (MessageHeader responses, ProgressSource pi, HttpURLConnection httpuc)

Parse the first line of the HTTP request. It usually looks something like: "HTTP/1.0 comment\r\n".

Throws
IOException

public static synchronized void resetProperties ()

This method is deprecated.
-- system properties are no longer cached.

A NOP method kept for backwards binary compatibility

public void setCacheRequest (CacheRequest cacheRequest)

public void setDoNotRetry (boolean value)

public int setTimeout (int timeout)

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
  • a string representation of the object.

public void writeRequests (MessageHeader head)

This method is deprecated.
No replacement.

public void writeRequests (MessageHeader head, PosterOutputStream pos)

Throws
IOException

Protected Methods

protected void finalize ()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Throws
Throwable

protected int getDefaultPort ()

return default port number (subclasses may override)

protected boolean isInKeepAliveCache ()

protected static Proxy newHttpProxy (String proxyHost, int proxyPort, String proto)

protected synchronized void openServer ()

Throws
IOException

protected synchronized void putInKeepAliveCache ()