@NotThreadSafe class CPoolProxy extends java.lang.Object implements ManagedHttpClientConnection, HttpContext
RESERVED_PREFIX| Constructor and Description |
|---|
CPoolProxy(CPoolEntry entry) |
| Modifier and Type | Method and Description |
|---|---|
void |
bind(java.net.Socket socket)
Binds this connection to the given socket.
|
void |
close()
Closes this connection gracefully.
|
(package private) CPoolEntry |
detach() |
static CPoolEntry |
detach(HttpClientConnection conn) |
void |
flush()
Writes out all pending buffered data over the open connection.
|
java.lang.Object |
getAttribute(java.lang.String id)
Obtains attribute with the given name.
|
(package private) ManagedHttpClientConnection |
getConnection() |
java.lang.String |
getId()
Returns connection ID which is expected to be unique
for the life span of the connection manager.
|
java.net.InetAddress |
getLocalAddress() |
int |
getLocalPort() |
HttpConnectionMetrics |
getMetrics()
Returns a collection of connection metrics.
|
(package private) CPoolEntry |
getPoolEntry() |
static CPoolEntry |
getPoolEntry(HttpClientConnection proxy) |
java.net.InetAddress |
getRemoteAddress() |
int |
getRemotePort() |
java.net.Socket |
getSocket()
Returns the underlying socket.
|
int |
getSocketTimeout()
Returns the socket timeout value.
|
javax.net.ssl.SSLSession |
getSSLSession()
Obtains the SSL session of the underlying connection, if any.
|
(package private) ManagedHttpClientConnection |
getValidConnection() |
boolean |
isOpen()
Checks if this connection is open.
|
boolean |
isResponseAvailable(int timeout)
Checks if response data is available from the connection.
|
boolean |
isStale()
Checks whether this connection has gone down.
|
static HttpClientConnection |
newProxy(CPoolEntry poolEntry) |
void |
receiveResponseEntity(HttpResponse response)
Receives the next response entity available from this connection and
attaches it to an existing HttpResponse object.
|
HttpResponse |
receiveResponseHeader()
Receives the request line and headers of the next response available from
this connection.
|
java.lang.Object |
removeAttribute(java.lang.String id)
Removes attribute with the given name from the context.
|
void |
sendRequestEntity(HttpEntityEnclosingRequest request)
Sends the request entity over the connection.
|
void |
sendRequestHeader(HttpRequest request)
Sends the request line and all headers over the connection.
|
void |
setAttribute(java.lang.String id,
java.lang.Object obj)
Sets value of the attribute with the given name.
|
void |
setSocketTimeout(int timeout)
Sets the socket timeout value.
|
void |
shutdown()
Force-closes this connection.
|
java.lang.String |
toString() |
CPoolProxy(CPoolEntry entry)
CPoolEntry getPoolEntry()
CPoolEntry detach()
ManagedHttpClientConnection getConnection()
ManagedHttpClientConnection getValidConnection()
public void close()
throws java.io.IOException
HttpConnectionshutdown instead.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface HttpConnectionjava.io.IOExceptionpublic void shutdown()
throws java.io.IOException
HttpConnectionshutdown in interface HttpConnectionjava.io.IOExceptionpublic boolean isOpen()
HttpConnectionisOpen in interface HttpConnectionpublic boolean isStale()
HttpConnectionisStale in interface HttpConnectiontrue if attempts to use this connection are
likely to succeed, or false if they are likely
to fail and this connection should be closedpublic void setSocketTimeout(int timeout)
HttpConnectionsetSocketTimeout in interface HttpConnectiontimeout - timeout value in millisecondspublic int getSocketTimeout()
HttpConnectiongetSocketTimeout in interface HttpConnection0 if timeout is disabled or -1 if
timeout is undefined.public java.lang.String getId()
ManagedHttpClientConnectiongetId in interface ManagedHttpClientConnectionpublic void bind(java.net.Socket socket)
throws java.io.IOException
ManagedHttpClientConnectionbind in interface ManagedHttpClientConnectionsocket - the socket to bind the connection to.java.io.IOExceptionpublic java.net.Socket getSocket()
ManagedHttpClientConnectiongetSocket in interface ManagedHttpClientConnectionpublic javax.net.ssl.SSLSession getSSLSession()
ManagedHttpClientConnectionSSLSocket, the SSL session of
that socket is obtained. This is a potentially blocking operation.getSSLSession in interface ManagedHttpClientConnectionnull otherwisepublic boolean isResponseAvailable(int timeout)
throws java.io.IOException
HttpClientConnectionisResponseAvailable in interface HttpClientConnectiontimeout - the maximum time in milliseconds to wait for datatimeout milliseconds.java.io.IOException - if an error happens on the connectionpublic void sendRequestHeader(HttpRequest request) throws HttpException, java.io.IOException
HttpClientConnectionsendRequestHeader in interface HttpClientConnectionrequest - the request whose headers to send.HttpException - in case of HTTP protocol violationjava.io.IOException - in case of an I/O errorpublic void sendRequestEntity(HttpEntityEnclosingRequest request) throws HttpException, java.io.IOException
HttpClientConnectionsendRequestEntity in interface HttpClientConnectionrequest - the request whose entity to send.HttpException - in case of HTTP protocol violationjava.io.IOException - in case of an I/O errorpublic HttpResponse receiveResponseHeader() throws HttpException, java.io.IOException
HttpClientConnectionreceiveResponseHeader in interface HttpClientConnectionHttpException - in case of HTTP protocol violationjava.io.IOException - in case of an I/O errorpublic void receiveResponseEntity(HttpResponse response) throws HttpException, java.io.IOException
HttpClientConnectionreceiveResponseEntity in interface HttpClientConnectionresponse - the response to attach the entity toHttpException - in case of HTTP protocol violationjava.io.IOException - in case of an I/O errorpublic void flush()
throws java.io.IOException
HttpClientConnectionflush in interface HttpClientConnectionjava.io.IOException - in case of an I/O errorpublic HttpConnectionMetrics getMetrics()
HttpConnectiongetMetrics in interface HttpConnectionpublic java.net.InetAddress getLocalAddress()
getLocalAddress in interface HttpInetConnectionpublic int getLocalPort()
getLocalPort in interface HttpInetConnectionpublic java.net.InetAddress getRemoteAddress()
getRemoteAddress in interface HttpInetConnectionpublic int getRemotePort()
getRemotePort in interface HttpInetConnectionpublic java.lang.Object getAttribute(java.lang.String id)
HttpContextgetAttribute in interface HttpContextid - the attribute name.null if not set.public void setAttribute(java.lang.String id,
java.lang.Object obj)
HttpContextsetAttribute in interface HttpContextid - the attribute name.obj - the attribute value.public java.lang.Object removeAttribute(java.lang.String id)
HttpContextremoveAttribute in interface HttpContextid - the attribute name.null if not set.public java.lang.String toString()
toString in class java.lang.Objectpublic static HttpClientConnection newProxy(CPoolEntry poolEntry)
public static CPoolEntry getPoolEntry(HttpClientConnection proxy)
public static CPoolEntry detach(HttpClientConnection conn)