FileDocCategorySizeDatePackage
ManagedClientConnection.javaAPI DocAndroid 1.5 API9860Wed May 06 22:41:10 BST 2009org.apache.http.conn

ManagedClientConnection

public interface ManagedClientConnection implements HttpClientConnection, HttpInetConnection, ConnectionReleaseTrigger
A client-side connection with advanced connection logic. Instances are typically obtained from a connection manager.
author
Roland Weber
version
$Revision: 672969 $
since
4.0

Fields Summary
Constructors Summary
Methods Summary
public org.apache.http.conn.routing.HttpRoutegetRoute()
Obtains the current route of this connection.

return
the route established so far, or null if not connected

public javax.net.ssl.SSLSessiongetSSLSession()
Obtains the SSL session of the underlying connection, if any. If this connection is open, and the underlying socket is an {@link javax.net.ssl.SSLSocket 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 {@link #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.

return
the underlying SSL session if available, null otherwise

public java.lang.ObjectgetState()
Returns the state object associated with this connection.

return
The state object

public booleanisMarkedReusable()
Indicates whether this connection is in a reusable communication state. See {@link #markReusable markReusable} and {@link #unmarkReusable unmarkReusable} for details.

return
true if this connection is marked as being in a reusable communication state, false otherwise

public booleanisSecure()
Indicates whether this connection is secure. The return value is well-defined only while the connection is open. It may change even while the connection is open.

return
true if this connection is secure, false otherwise

public voidlayerProtocol(org.apache.http.protocol.HttpContext context, org.apache.http.params.HttpParams params)
Layers a new protocol on top of a {@link #tunnelTarget tunnelled} connection. This is typically used to create a TLS/SSL connection through a proxy. The route is the one previously passed to {@link #open open}. It is not guaranteed that the layered connection is {@link #isSecure secure}.

param
context the context for layering on top of this connection
param
params the parameters for layering on top of this connection
throws
IOException in case of a problem

public voidmarkReusable()
Marks this connection as being in a reusable communication state. The checkpoints for reuseable communication states (in the absence of pipelining) are before sending a request and after receiving the response in it's entirety. The connection will automatically clear the checkpoint when used for communication. A call to this method indicates that the next checkpoint has been reached.
A reusable communication state is necessary but not sufficient for the connection to be reused. A {@link #getRoute route} mismatch, the connection being closed, or other circumstances might prevent reuse.

public voidopen(org.apache.http.conn.routing.HttpRoute route, org.apache.http.protocol.HttpContext context, org.apache.http.params.HttpParams params)
Opens this connection according to the given route.

param
route the route along which to open. It will be opened to the first proxy if present, or directly to the target.
param
context the context for opening this connection
param
params the parameters for opening this connection
throws
IOException in case of a problem

public voidsetIdleDuration(long duration, java.util.concurrent.TimeUnit unit)
Sets the duration that this connection can remain idle before it is reused. The connection should not be used again if this time elapses. The idle duration must be reset after each request sent over this connection. The elapsed time starts counting when the connection is released, which is typically after the headers (and any response body, if present) is fully consumed.

public voidsetState(java.lang.Object state)
Assigns a state object to this connection. Connection managers may make use of the connection state when allocating persistent connections.

param
state The state object

public voidtunnelProxy(org.apache.http.HttpHost next, boolean secure, org.apache.http.params.HttpParams params)
Indicates that a tunnel to an intermediate proxy has been established. This is used exclusively for so-called proxy chains, where a request has to pass through multiple proxies before reaching the target. In that case, all proxies but the last need to be tunnelled when establishing the connection. Tunnelling of the last proxy to the target is optional and would be indicated via {@link #tunnelTarget}.

param
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 {@link #tunnelTarget} to indicate an end-to-end tunnel.
param
secure true if the connection should be considered secure, false otherwise
param
params the parameters for tunnelling this connection
throws
IOException in case of a problem

public voidtunnelTarget(boolean secure, org.apache.http.params.HttpParams params)
Indicates that a tunnel to the target has been established. The route is the one previously passed to {@link #open open}. Subsequently, {@link #layerProtocol 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.

param
secure true if the tunnel should be considered secure, false otherwise
param
params the parameters for tunnelling this connection
throws
IOException in case of a problem

public voidunmarkReusable()
Marks this connection as not being in a reusable state. This can be used immediately before releasing this connection to prevent it's reuse. Reasons for preventing reuse include error conditions and the evaluation of a {@link org.apache.http.ConnectionReuseStrategy 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 {@link #markReusable markReusable}.