ManagedHttpClientConnectionFactory
.@Deprecated @NotThreadSafe class ManagedClientConnectionImpl extends java.lang.Object implements ManagedClientConnection
Constructor and Description |
---|
ManagedClientConnectionImpl(ClientConnectionManager manager,
ClientConnectionOperator operator,
HttpPoolEntry entry)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
abortConnection()
Deprecated.
Releases the connection without the option of keep-alive.
|
void |
bind(java.net.Socket socket)
Deprecated.
Binds this connection to the given socket.
|
void |
close()
Deprecated.
Closes this connection gracefully.
|
(package private) HttpPoolEntry |
detach()
Deprecated.
|
void |
flush()
Deprecated.
Writes out all pending buffered data over the open connection.
|
java.lang.Object |
getAttribute(java.lang.String id)
Deprecated.
|
java.lang.String |
getId()
Deprecated.
Returns connection ID which is expected to be unique
for the life span of the connection manager.
|
java.net.InetAddress |
getLocalAddress()
Deprecated.
|
int |
getLocalPort()
Deprecated.
|
ClientConnectionManager |
getManager()
Deprecated.
|
HttpConnectionMetrics |
getMetrics()
Deprecated.
Returns a collection of connection metrics.
|
(package private) HttpPoolEntry |
getPoolEntry()
Deprecated.
|
java.net.InetAddress |
getRemoteAddress()
Deprecated.
|
int |
getRemotePort()
Deprecated.
|
HttpRoute |
getRoute()
Deprecated.
Obtains the current route of this connection.
|
java.net.Socket |
getSocket()
Deprecated.
Returns the underlying socket.
|
int |
getSocketTimeout()
Deprecated.
Returns the socket timeout value.
|
javax.net.ssl.SSLSession |
getSSLSession()
Deprecated.
Obtains the SSL session of the underlying connection, if any.
|
java.lang.Object |
getState()
Deprecated.
Returns the state object associated with this connection.
|
boolean |
isMarkedReusable()
Deprecated.
Indicates whether this connection is in a reusable communication state.
|
boolean |
isOpen()
Deprecated.
Checks if this connection is open.
|
boolean |
isResponseAvailable(int timeout)
Deprecated.
Checks if response data is available from the connection.
|
boolean |
isSecure()
Deprecated.
Indicates whether this connection is secure.
|
boolean |
isStale()
Deprecated.
Checks whether this connection has gone down.
|
void |
layerProtocol(HttpContext context,
HttpParams params)
Deprecated.
Layers a new protocol on top of a
tunnelled
connection. |
void |
markReusable()
Deprecated.
Marks this connection as being in a reusable communication state.
|
void |
open(HttpRoute route,
HttpContext context,
HttpParams params)
Deprecated.
Opens this connection according to the given route.
|
void |
receiveResponseEntity(HttpResponse response)
Deprecated.
Receives the next response entity available from this connection and
attaches it to an existing HttpResponse object.
|
HttpResponse |
receiveResponseHeader()
Deprecated.
Receives the request line and headers of the next response available from
this connection.
|
void |
releaseConnection()
Deprecated.
Releases the connection with the option of keep-alive.
|
java.lang.Object |
removeAttribute(java.lang.String id)
Deprecated.
|
void |
sendRequestEntity(HttpEntityEnclosingRequest request)
Deprecated.
Sends the request entity over the connection.
|
void |
sendRequestHeader(HttpRequest request)
Deprecated.
Sends the request line and all headers over the connection.
|
void |
setAttribute(java.lang.String id,
java.lang.Object obj)
Deprecated.
|
void |
setIdleDuration(long duration,
java.util.concurrent.TimeUnit unit)
Deprecated.
Sets the duration that this connection can remain idle before it is
reused.
|
void |
setSocketTimeout(int timeout)
Deprecated.
Sets the socket timeout value.
|
void |
setState(java.lang.Object state)
Deprecated.
Assigns a state object to this connection.
|
void |
shutdown()
Deprecated.
Force-closes this connection.
|
void |
tunnelProxy(HttpHost next,
boolean secure,
HttpParams params)
Deprecated.
Indicates that a tunnel to an intermediate proxy has been established.
|
void |
tunnelTarget(boolean secure,
HttpParams params)
Deprecated.
Indicates that a tunnel to the target has been established.
|
void |
unmarkReusable()
Deprecated.
Marks this connection as not being in a reusable state.
|
ManagedClientConnectionImpl(ClientConnectionManager manager, ClientConnectionOperator operator, HttpPoolEntry entry)
public java.lang.String getId()
ManagedHttpClientConnection
getId
in interface ManagedHttpClientConnection
HttpPoolEntry getPoolEntry()
HttpPoolEntry detach()
public ClientConnectionManager getManager()
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 HttpConnectionMetrics getMetrics()
HttpConnection
getMetrics
in interface HttpConnection
public void flush() throws java.io.IOException
HttpClientConnection
flush
in interface HttpClientConnection
java.io.IOException
- in case of an I/O errorpublic 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 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 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 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 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 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 boolean isSecure()
ManagedClientConnection
isSecure
in interface HttpRoutedConnection
isSecure
in interface ManagedClientConnection
true
if this connection is secure,
false
otherwisepublic 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()
ManagedClientConnection
SSLSocket
, the SSL session of
that socket is obtained. This is a potentially blocking operation.
Note: Whether the underlying socket is an SSL socket
can not necessarily be determined via ManagedClientConnection.isSecure()
.
Plain sockets may be considered secure, for example if they are
connected to a known host in the same network segment.
On the other hand, SSL sockets may be considered insecure,
for example depending on the chosen cipher suite.
getSSLSession
in interface HttpRoutedConnection
getSSLSession
in interface ManagedClientConnection
getSSLSession
in interface ManagedHttpClientConnection
null
otherwisepublic java.lang.Object getAttribute(java.lang.String id)
public java.lang.Object removeAttribute(java.lang.String id)
public void setAttribute(java.lang.String id, java.lang.Object obj)
public HttpRoute getRoute()
ManagedClientConnection
getRoute
in interface HttpRoutedConnection
getRoute
in interface ManagedClientConnection
null
if not connectedpublic void open(HttpRoute route, HttpContext context, HttpParams params) throws java.io.IOException
ManagedClientConnection
open
in interface ManagedClientConnection
route
- the route along which to open. It will be opened to
the first proxy if present, or directly to the target.context
- the context for opening this connectionparams
- the parameters for opening this connectionjava.io.IOException
- in case of a problempublic void tunnelTarget(boolean secure, HttpParams params) throws java.io.IOException
ManagedClientConnection
open
.
Subsequently, layerProtocol
can be called
to layer the TLS/SSL protocol on top of the tunnelled connection.
Note: In HttpClient 3, a call to the corresponding method would automatically trigger the layering of the TLS/SSL protocol. This is not the case anymore, you can establish a tunnel without layering a new protocol over the connection.
tunnelTarget
in interface ManagedClientConnection
secure
- true
if the tunnel should be considered
secure, false
otherwiseparams
- the parameters for tunnelling this connectionjava.io.IOException
- in case of a problempublic void tunnelProxy(HttpHost next, boolean secure, HttpParams params) throws java.io.IOException
ManagedClientConnection
ManagedClientConnection.tunnelTarget(boolean, org.apache.http.params.HttpParams)
.tunnelProxy
in interface ManagedClientConnection
next
- the proxy to which the tunnel was established.
This is not the proxy through which
the tunnel was established, but the new end point
of the tunnel. The tunnel does not yet
reach to the target, use ManagedClientConnection.tunnelTarget(boolean, org.apache.http.params.HttpParams)
to indicate an end-to-end tunnel.secure
- true
if the connection should be
considered secure, false
otherwiseparams
- the parameters for tunnelling this connectionjava.io.IOException
- in case of a problempublic void layerProtocol(HttpContext context, HttpParams params) throws java.io.IOException
ManagedClientConnection
tunnelled
connection. This is typically used to create a TLS/SSL connection
through a proxy.
The route is the one previously passed to open
.
It is not guaranteed that the layered connection is
secure
.layerProtocol
in interface ManagedClientConnection
context
- the context for layering on top of this connectionparams
- the parameters for layering on top of this connectionjava.io.IOException
- in case of a problempublic java.lang.Object getState()
ManagedClientConnection
getState
in interface ManagedClientConnection
public void setState(java.lang.Object state)
ManagedClientConnection
setState
in interface ManagedClientConnection
state
- The state objectpublic void markReusable()
ManagedClientConnection
A reusable communication state is necessary but not sufficient
for the connection to be reused.
A route
mismatch, the connection being closed,
or other circumstances might prevent reuse.
markReusable
in interface ManagedClientConnection
public void unmarkReusable()
ManagedClientConnection
reuse strategy
.
Note:
It is not necessary to call here before writing to
or reading from this connection. Communication attempts will
automatically unmark the state as non-reusable. It can then
be switched back using markReusable
.
unmarkReusable
in interface ManagedClientConnection
public boolean isMarkedReusable()
ManagedClientConnection
markReusable
and
unmarkReusable
for details.isMarkedReusable
in interface ManagedClientConnection
true
if this connection is marked as being in
a reusable communication state,
false
otherwisepublic void setIdleDuration(long duration, java.util.concurrent.TimeUnit unit)
ManagedClientConnection
setIdleDuration
in interface ManagedClientConnection
public void releaseConnection()
ConnectionReleaseTrigger
abortConnection
for a hard release. The
connection may be reused as specified by the duration.releaseConnection
in interface ConnectionReleaseTrigger
public void abortConnection()
ConnectionReleaseTrigger
ConnectionReleaseTrigger.releaseConnection()
for a graceful release.abortConnection
in interface ConnectionReleaseTrigger