org.apache.http.conn
Interface ManagedClientConnection

All Superinterfaces:
ConnectionReleaseTrigger, org.apache.http.HttpClientConnection, org.apache.http.HttpConnection, org.apache.http.HttpInetConnection
All Known Implementing Classes:
AbstractClientConnAdapter, AbstractPooledConnAdapter, SingleClientConnManager.ConnAdapter

public interface ManagedClientConnection
extends org.apache.http.HttpClientConnection, org.apache.http.HttpInetConnection, ConnectionReleaseTrigger

A client-side connection with advanced connection logic. Instances are typically obtained from a connection manager.

Since:
4.0
Version:
$Revision: 508919 $
Author:
Roland Weber

Method Summary
 HttpRoute getRoute()
          Obtains the current route of this connection.
 boolean isMarkedReusable()
          Indicates whether this connection is in a reusable communication state.
 boolean isSecure()
          Indicates whether this connection is secure.
 void layerProtocol(org.apache.http.protocol.HttpContext context, org.apache.http.params.HttpParams params)
          Layers a new protocol on top of a tunnelled connection.
 void markReusable()
          Marks this connection as being in a reusable communication state.
 void open(HttpRoute route, org.apache.http.protocol.HttpContext context, org.apache.http.params.HttpParams params)
          Opens this connection according to the given route.
 void tunnelCreated(boolean secure, org.apache.http.params.HttpParams params)
          Indicates that a tunnel has been established.
 void unmarkReusable()
          Marks this connection as not being in a reusable state.
 
Methods inherited from interface org.apache.http.HttpClientConnection
flush, isResponseAvailable, receiveResponseEntity, receiveResponseHeader, sendRequestEntity, sendRequestHeader
 
Methods inherited from interface org.apache.http.HttpConnection
close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdown
 
Methods inherited from interface org.apache.http.HttpInetConnection
getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort
 
Methods inherited from interface org.apache.http.HttpConnection
close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdown
 
Methods inherited from interface org.apache.http.conn.ConnectionReleaseTrigger
abortConnection, releaseConnection
 

Method Detail

isSecure

boolean isSecure()
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.

Returns:
true if this connection is secure, false otherwise

getRoute

HttpRoute getRoute()
Obtains the current route of this connection.

Returns:
the route established so far, or null if not connected

open

void open(HttpRoute route,
          org.apache.http.protocol.HttpContext context,
          org.apache.http.params.HttpParams params)
          throws java.io.IOException
Opens this connection according to the given route.

Parameters:
route - the route along which to open. It will be opened to the proxy if present, or directly to the target.
context - the context for opening this connection
params - the parameters for opening this connection
Throws:
java.io.IOException - in case of a problem

tunnelCreated

void tunnelCreated(boolean secure,
                   org.apache.http.params.HttpParams params)
                   throws java.io.IOException
Indicates that a tunnel has been established. The route is the one previously passed to 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.

Parameters:
secure - true if the tunnel should be considered secure, false otherwise
params - the parameters for tunnelling this connection
Throws:
java.io.IOException - in case of a problem

layerProtocol

void layerProtocol(org.apache.http.protocol.HttpContext context,
                   org.apache.http.params.HttpParams params)
                   throws java.io.IOException
Layers a new protocol on top of a 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.

Parameters:
context - the context for layering on top of this connection
params - the parameters for layering on top of this connection
Throws:
java.io.IOException - in case of a problem

markReusable

void markReusable()
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 route mismatch, the connection being closed, or other circumstances might prevent reuse.


unmarkReusable

void unmarkReusable()
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 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.


isMarkedReusable

boolean isMarkedReusable()
Indicates whether this connection is in a reusable communication state. See markReusable and unmarkReusable for details.

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


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.