class CPoolProxy extends Object implements ManagedHttpClientConnection, HttpContext
Modifier and Type | Field and Description |
---|---|
private CPoolEntry |
poolEntry |
RESERVED_PREFIX
Constructor and Description |
---|
CPoolProxy(CPoolEntry entry) |
Modifier and Type | Method and Description |
---|---|
void |
bind(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.
|
Object |
getAttribute(String id)
Obtains attribute with the given name.
|
(package private) ManagedHttpClientConnection |
getConnection() |
String |
getId()
Returns connection ID which is expected to be unique
for the life span of the connection manager.
|
InetAddress |
getLocalAddress() |
int |
getLocalPort() |
HttpConnectionMetrics |
getMetrics()
Returns a collection of connection metrics.
|
(package private) CPoolEntry |
getPoolEntry() |
static CPoolEntry |
getPoolEntry(HttpClientConnection proxy) |
private static CPoolProxy |
getProxy(HttpClientConnection conn) |
InetAddress |
getRemoteAddress() |
int |
getRemotePort() |
Socket |
getSocket()
Returns the underlying socket.
|
int |
getSocketTimeout()
Returns the socket timeout value.
|
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.
|
Object |
removeAttribute(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(String id,
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.
|
String |
toString() |
private volatile CPoolEntry poolEntry
CPoolProxy(CPoolEntry entry)
CPoolEntry getPoolEntry()
CPoolEntry detach()
ManagedHttpClientConnection getConnection()
ManagedHttpClientConnection getValidConnection()
public void close() throws IOException
HttpConnection
shutdown
instead.close
in interface Closeable
close
in interface AutoCloseable
close
in interface HttpConnection
IOException
public void shutdown() throws IOException
HttpConnection
shutdown
in interface HttpConnection
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 String getId()
ManagedHttpClientConnection
getId
in interface ManagedHttpClientConnection
public void bind(Socket socket) throws IOException
ManagedHttpClientConnection
bind
in interface ManagedHttpClientConnection
socket
- the socket to bind the connection to.IOException
public Socket getSocket()
ManagedHttpClientConnection
getSocket
in interface ManagedHttpClientConnection
public 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 IOException
HttpClientConnection
isResponseAvailable
in interface HttpClientConnection
timeout
- the maximum time in milliseconds to wait for datatimeout
milliseconds.IOException
- if an error happens on the connectionpublic void sendRequestHeader(HttpRequest request) throws HttpException, IOException
HttpClientConnection
sendRequestHeader
in interface HttpClientConnection
request
- the request whose headers to send.HttpException
- in case of HTTP protocol violationIOException
- in case of an I/O errorpublic void sendRequestEntity(HttpEntityEnclosingRequest request) throws HttpException, IOException
HttpClientConnection
sendRequestEntity
in interface HttpClientConnection
request
- the request whose entity to send.HttpException
- in case of HTTP protocol violationIOException
- in case of an I/O errorpublic HttpResponse receiveResponseHeader() throws HttpException, IOException
HttpClientConnection
receiveResponseHeader
in interface HttpClientConnection
HttpException
- in case of HTTP protocol violationIOException
- in case of an I/O errorpublic void receiveResponseEntity(HttpResponse response) throws HttpException, IOException
HttpClientConnection
receiveResponseEntity
in interface HttpClientConnection
response
- the response to attach the entity toHttpException
- in case of HTTP protocol violationIOException
- in case of an I/O errorpublic void flush() throws IOException
HttpClientConnection
flush
in interface HttpClientConnection
IOException
- in case of an I/O errorpublic HttpConnectionMetrics getMetrics()
HttpConnection
getMetrics
in interface HttpConnection
public InetAddress getLocalAddress()
getLocalAddress
in interface HttpInetConnection
public int getLocalPort()
getLocalPort
in interface HttpInetConnection
public InetAddress getRemoteAddress()
getRemoteAddress
in interface HttpInetConnection
public int getRemotePort()
getRemotePort
in interface HttpInetConnection
public Object getAttribute(String id)
HttpContext
getAttribute
in interface HttpContext
id
- the attribute name.null
if not set.public void setAttribute(String id, Object obj)
HttpContext
setAttribute
in interface HttpContext
id
- the attribute name.obj
- the attribute value.public Object removeAttribute(String id)
HttpContext
removeAttribute
in interface HttpContext
id
- the attribute name.null
if not set.public static HttpClientConnection newProxy(CPoolEntry poolEntry)
private static CPoolProxy getProxy(HttpClientConnection conn)
public static CPoolEntry getPoolEntry(HttpClientConnection proxy)
public static CPoolEntry detach(HttpClientConnection conn)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses