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()
ManagedHttpClientConnectiongetId in interface ManagedHttpClientConnectionHttpPoolEntry getPoolEntry()
HttpPoolEntry detach()
public ClientConnectionManager getManager()
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 HttpConnectionMetrics getMetrics()
HttpConnectiongetMetrics in interface HttpConnectionpublic void flush()
throws java.io.IOException
HttpClientConnectionflush in interface HttpClientConnectionjava.io.IOException - in case of an I/O errorpublic 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 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 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 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 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 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 boolean isSecure()
ManagedClientConnectionisSecure in interface HttpRoutedConnectionisSecure in interface ManagedClientConnectiontrue if this connection is secure,
false otherwisepublic 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()
ManagedClientConnectionSSLSocket, 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 HttpRoutedConnectiongetSSLSession in interface ManagedClientConnectiongetSSLSession in interface ManagedHttpClientConnectionnull 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()
ManagedClientConnectiongetRoute in interface HttpRoutedConnectiongetRoute in interface ManagedClientConnectionnull if not connectedpublic void open(HttpRoute route, HttpContext context, HttpParams params) throws java.io.IOException
ManagedClientConnectionopen in interface ManagedClientConnectionroute - 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
ManagedClientConnectionopen.
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 ManagedClientConnectionsecure - 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
ManagedClientConnectionManagedClientConnection.tunnelTarget(boolean, org.apache.http.params.HttpParams).tunnelProxy in interface ManagedClientConnectionnext - 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
ManagedClientConnectiontunnelled
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 ManagedClientConnectioncontext - 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()
ManagedClientConnectiongetState in interface ManagedClientConnectionpublic void setState(java.lang.Object state)
ManagedClientConnectionsetState in interface ManagedClientConnectionstate - 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 ManagedClientConnectionpublic void unmarkReusable()
ManagedClientConnectionreuse 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 ManagedClientConnectionpublic boolean isMarkedReusable()
ManagedClientConnectionmarkReusable and
unmarkReusable for details.isMarkedReusable in interface ManagedClientConnectiontrue if this connection is marked as being in
a reusable communication state,
false otherwisepublic void setIdleDuration(long duration,
java.util.concurrent.TimeUnit unit)
ManagedClientConnectionsetIdleDuration in interface ManagedClientConnectionpublic void releaseConnection()
ConnectionReleaseTriggerabortConnection for a hard release. The
connection may be reused as specified by the duration.releaseConnection in interface ConnectionReleaseTriggerpublic void abortConnection()
ConnectionReleaseTriggerConnectionReleaseTrigger.releaseConnection() for a graceful release.abortConnection in interface ConnectionReleaseTrigger