Top Fields Constructors Methods
sun.net.www.http

public Class HttpClient

extends NetworkClient
Class Inheritance
Known Direct Subclasses
sun.net.www.protocol.https.HttpsClient
Imports
java.io.*, java.net.*, java.util.Locale, .Objects, .OptionalInt, .Properties, java.util.concurrent.locks.ReentrantLock, sun.net.NetworkClient, sun.net.www.MessageHeader, .HeaderParser, .MeteredStream, .ParseUtil, sun.net.www.protocol.http.AuthCacheImpl, .HttpURLConnection, sun.util.logging.PlatformLogger, sun.security.action.GetPropertyAction

Authors
Herb Jellinek, Dave Brown

Field Summary

Modifier and TypeField and Description
protected volatile AuthCacheImpl
protected boolean
private static final boolean
private CacheRequest
cacheRequest

whether the response is to be cached

private static final boolean
private HttpCapture
private final ReentrantLock
pack-priv volatile boolean
pack-priv boolean
protected String
private static final int
pack-priv static final int
httpPortNumber

Default port number for http daemons.

private boolean
ignoreContinue

Response code for CONTINUE

protected boolean
protected static final KeepAliveCache
pack-priv int
private static final boolean
pack-priv int
pack-priv volatile boolean
private static final PlatformLogger
protected int
pack-priv PosterOutputStream
protected boolean
pack-priv MessageHeader
private static final boolean
public boolean
private static final String
pack-priv boolean
protected URL
url

Url being fetched.

public boolean
Inherited from sun.net.NetworkClient:
connectTimeoutDEFAULT_CONNECT_TIMEOUTDEFAULT_READ_TIMEOUTdefaultConnectTimeoutdefaultSoTimeoutencodingproxyreadTimeoutserverInputserverOutputserverSocket

Constructor Summary

AccessConstructor and Description
protected
private
protected
HttpClient(URL url, boolean proxyDisabled)

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

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

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

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

Method Summary

Modifier and TypeMethod and Description
public void
protected boolean
private void
public void
public void
closeServer()

Overrides sun.net.NetworkClient.closeServer.

Close an open connection to the server.
public void
public final AuthCacheImpl
pack-priv CacheRequest
protected int
getDefaultPort()

return default port number (subclasses may override)

private static int
public boolean

Returns:

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

public InputStream
pack-priv int
public OutputStream
public String

Returns:

the proxy host being used for this client, or null if we're not going through a proxy
getProxyHostUsed
()

public int

Returns:

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

pack-priv String
public String
public String
public boolean
public boolean
protected boolean
public final boolean
public final void
lock()

private static void
private static void
public boolean
public static HttpClient
New(URL url)

public static HttpClient
New(URL url, boolean useCache)

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

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

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

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

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

pack-priv static String
public void
openServer(String server, int port)

Overrides sun.net.NetworkClient.openServer.

Open a connection to the server.
protected void
public boolean
parseHTTP(MessageHeader responses, HttpURLConnection httpuc)

Parse the first line of the HTTP request.

private boolean
private void
protected void
public static synchronized void
resetProperties()

Deprecated -- system properties are no longer cached.
A NOP method kept for backwards binary compatibility
public void
public void
setDoNotRetry(boolean value)

public void
setIgnoreContinue(boolean value)

private void
superOpenServer(final String proxyHost, final int proxyPort)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public final void
public void
writeRequests(MessageHeader head)

Deprecated
public void
public void
writeRequests(MessageHeader head, PosterOutputStream pos, boolean streaming)

Inherited from sun.net.NetworkClient:
createSocketdoConnectgetConnectTimeoutgetLocalAddressgetReadTimeoutserverIsOpensetConnectTimeoutsetReadTimeout

Field Detail

authcacheback to summary
protected volatile AuthCacheImpl authcache
cachedHttpClientback to summary
protected boolean cachedHttpClient
cacheNTLMPropback to summary
private static final boolean cacheNTLMProp
cacheRequestback to summary
private CacheRequest cacheRequest

whether the response is to be cached

cacheSPNEGOPropback to summary
private static final boolean cacheSPNEGOProp
captureback to summary
private HttpCapture capture
clientLockback to summary
private final ReentrantLock clientLock
disableKeepAliveback to summary
pack-priv volatile boolean disableKeepAlive
failedOnceback to summary
pack-priv boolean failedOnce
hostback to summary
protected String host
HTTP_CONTINUEback to summary
private static final int HTTP_CONTINUE
httpPortNumberback to summary
pack-priv static final int httpPortNumber

Default port number for http daemons. REMIND: make these private

ignoreContinueback to summary
private boolean ignoreContinue

Response code for CONTINUE

inCacheback to summary
protected boolean inCache
kacback to summary
protected static final KeepAliveCache kac
keepAliveConnectionsback to summary
pack-priv int keepAliveConnections
keepAlivePropback to summary
private static final boolean keepAliveProp
keepAliveTimeoutback to summary
pack-priv int keepAliveTimeout
keepingAliveback to summary
pack-priv volatile boolean keepingAlive
loggerback to summary
private static final PlatformLogger logger
portback to summary
protected int port
posterback to summary
pack-priv PosterOutputStream poster
proxyDisabledback to summary
protected boolean proxyDisabled
requestsback to summary
pack-priv MessageHeader requests
retryPostPropback to summary
private static final boolean retryPostProp
reuseback to summary
public boolean reuse
spnegoCBTback to summary
private static final String spnegoCBT
streamingback to summary
pack-priv boolean streaming
urlback to summary
protected URL url

Url being fetched.

usingProxyback to summary
public boolean usingProxy

Constructor Detail

HttpClientback to summary
protected HttpClient()
HttpClientback to summary
private HttpClient(URL url) throws IOException
HttpClientback to summary
protected HttpClient(URL url, boolean proxyDisabled) throws IOException
HttpClientback to summary
public HttpClient(URL url, String proxyHost, int proxyPort) throws IOException
HttpClientback to summary
protected HttpClient(URL url, Proxy p, int to) throws IOException
HttpClientback to summary
private HttpClient(URL url, String proxyHost, int proxyPort, boolean proxyDisabled) throws IOException
HttpClientback to summary
public HttpClient(URL url, String proxyHost, int proxyPort, boolean proxyDisabled, int to) throws IOException

Method Detail

afterConnectback to summary
public void afterConnect() throws IOException, UnknownHostException
availableback to summary
protected boolean available()
checkTunnelingback to summary
private void checkTunneling(HttpURLConnection httpuc) throws IOException
closeIdleConnectionback to summary
public void closeIdleConnection()
closeServerback to summary
public void closeServer()

Overrides sun.net.NetworkClient.closeServer.

Doc from sun.net.NetworkClient.closeServer.

Close an open connection to the server.

Annotations
@Override
finishedback to summary
public void finished()
getAuthCacheback to summary
public final AuthCacheImpl getAuthCache()
getCacheRequestback to summary
pack-priv CacheRequest getCacheRequest()
getDefaultPortback to summary
protected int getDefaultPort()

return default port number (subclasses may override)

getDefaultPortback to summary
private static int getDefaultPort(String proto)
getHttpKeepAliveSetback to summary
public boolean getHttpKeepAliveSet()
Returns:boolean

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

getInputStreamback to summary
public InputStream getInputStream()
getKeepAliveTimeoutback to summary
pack-priv int getKeepAliveTimeout()
getOutputStreamback to summary
public OutputStream getOutputStream()
getProxyHostUsedback to summary
public String getProxyHostUsed()
Returns:String

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

getProxyPortUsedback to summary
public int getProxyPortUsed()
Returns:int

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

getRequestMethodback to summary
pack-priv String getRequestMethod()
getSpnegoCBTback to summary
public String getSpnegoCBT()
getURLFileback to summary
public String getURLFile() throws IOException
getUsingProxyback to summary
public boolean getUsingProxy()
isCachedConnectionback to summary
public boolean isCachedConnection()
isInKeepAliveCacheback to summary
protected boolean isInKeepAliveCache()
isKeepingAliveback to summary
public final boolean isKeepingAlive()
lockback to summary
public final void lock()
logErrorback to summary
private static void logError(String msg)
logFinestback to summary
private static void logFinest(String msg)
needsTunnelingback to summary
public boolean needsTunneling()
Newback to summary
public static HttpClient New(URL url) throws IOException
Newback to summary
public static HttpClient New(URL url, boolean useCache) throws IOException
Newback to summary
public static HttpClient New(URL url, Proxy p, int to, boolean useCache, HttpURLConnection httpuc) throws IOException
Newback to summary
public static HttpClient New(URL url, Proxy p, int to, HttpURLConnection httpuc) throws IOException
Newback to summary
public static HttpClient New(URL url, String proxyHost, int proxyPort, boolean useCache) throws IOException
Newback to summary
public static HttpClient New(URL url, String proxyHost, int proxyPort, boolean useCache, int to, HttpURLConnection httpuc) throws IOException
newHttpProxyback to summary
protected static Proxy newHttpProxy(String proxyHost, int proxyPort, String proto)
normalizeCBTback to summary
pack-priv static String normalizeCBT(String s)
openServerback to summary
public void openServer(String server, int port) throws IOException

Overrides sun.net.NetworkClient.openServer.

Doc from sun.net.NetworkClient.openServer.

Open a connection to the server.

Annotations
@Override
openServerback to summary
protected void openServer() throws IOException
parseHTTPback to summary
public boolean parseHTTP(MessageHeader responses, HttpURLConnection httpuc) throws IOException

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

parseHTTPHeaderback to summary
private boolean parseHTTPHeader(MessageHeader responses, HttpURLConnection httpuc) throws IOException
privilegedOpenServerback to summary
private void privilegedOpenServer(final InetSocketAddress server) throws IOException
Annotations
@SuppressWarnings:removal
putInKeepAliveCacheback to summary
protected void putInKeepAliveCache()
resetPropertiesback to summary
public static synchronized void resetProperties()

Deprecated

-- system properties are no longer cached.

A NOP method kept for backwards binary compatibility

Annotations
@Deprecated
setCacheRequestback to summary
public void setCacheRequest(CacheRequest cacheRequest)
setDoNotRetryback to summary
public void setDoNotRetry(boolean value)
setIgnoreContinueback to summary
public void setIgnoreContinue(boolean value)
superOpenServerback to summary
private void superOpenServer(final String proxyHost, final int proxyPort) throws IOException, UnknownHostException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
unlockback to summary
public final void unlock()
writeRequestsback to summary
public void writeRequests(MessageHeader head)

Deprecated

Annotations
@Deprecated
writeRequestsback to summary
public void writeRequests(MessageHeader head, PosterOutputStream pos) throws IOException
writeRequestsback to summary
public void writeRequests(MessageHeader head, PosterOutputStream pos, boolean streaming) throws IOException