@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
HttpConnection
shutdown
instead.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface HttpConnection
java.io.IOException
public void shutdown() throws java.io.IOException
HttpConnection
shutdown
in interface HttpConnection
java.io.IOException
public boolean isOpen()
HttpConnection
isOpen
in interface HttpConnection
public boolean isStale()
HttpConnection
isStale
in interface HttpConnection
true
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)
HttpConnection
setSocketTimeout
in interface HttpConnection
timeout
- timeout value in millisecondspublic int getSocketTimeout()
HttpConnection
getSocketTimeout
in interface HttpConnection
0
if timeout is disabled or -1
if
timeout is undefined.public java.lang.String getId()
ManagedHttpClientConnection
getId
in interface ManagedHttpClientConnection
public void bind(java.net.Socket socket) throws java.io.IOException
ManagedHttpClientConnection
bind
in interface ManagedHttpClientConnection
socket
- the socket to bind the connection to.java.io.IOException
public java.net.Socket getSocket()
ManagedHttpClientConnection
getSocket
in interface ManagedHttpClientConnection
public javax.net.ssl.SSLSession getSSLSession()
ManagedHttpClientConnection
SSLSocket
, the SSL session of
that socket is obtained. This is a potentially blocking operation.getSSLSession
in interface ManagedHttpClientConnection
null
otherwisepublic boolean isResponseAvailable(int timeout) throws java.io.IOException
HttpClientConnection
isResponseAvailable
in interface HttpClientConnection
timeout
- 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
HttpClientConnection
sendRequestHeader
in interface HttpClientConnection
request
- 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
HttpClientConnection
sendRequestEntity
in interface HttpClientConnection
request
- 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
HttpClientConnection
receiveResponseHeader
in interface HttpClientConnection
HttpException
- in case of HTTP protocol violationjava.io.IOException
- in case of an I/O errorpublic void receiveResponseEntity(HttpResponse response) throws HttpException, java.io.IOException
HttpClientConnection
receiveResponseEntity
in interface HttpClientConnection
response
- 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
HttpClientConnection
flush
in interface HttpClientConnection
java.io.IOException
- in case of an I/O errorpublic HttpConnectionMetrics getMetrics()
HttpConnection
getMetrics
in interface HttpConnection
public java.net.InetAddress getLocalAddress()
getLocalAddress
in interface HttpInetConnection
public int getLocalPort()
getLocalPort
in interface HttpInetConnection
public java.net.InetAddress getRemoteAddress()
getRemoteAddress
in interface HttpInetConnection
public int getRemotePort()
getRemotePort
in interface HttpInetConnection
public java.lang.Object getAttribute(java.lang.String id)
HttpContext
getAttribute
in interface HttpContext
id
- the attribute name.null
if not set.public void setAttribute(java.lang.String id, java.lang.Object obj)
HttpContext
setAttribute
in interface HttpContext
id
- the attribute name.obj
- the attribute value.public java.lang.Object removeAttribute(java.lang.String id)
HttpContext
removeAttribute
in interface HttpContext
id
- the attribute name.null
if not set.public java.lang.String toString()
toString
in class java.lang.Object
public static HttpClientConnection newProxy(CPoolEntry poolEntry)
public static CPoolEntry getPoolEntry(HttpClientConnection proxy)
public static CPoolEntry detach(HttpClientConnection conn)