The lowest layer of connection handling is comprised of {@link org.apache.http.conn.OperatedClientConnection OperatedClientConnection} and {@link org.apache.http.conn.ClientConnectionOperator ClientConnectionOperator}. The connection interface extends the core {@link org.apache.http.HttpClientConnection HttpClientConnection} by operations to set and update a socket. An operator encapsulates the logic to open and layer sockets, typically using a {@link org.apache.http.conn.SocketFactory SocketFactory}. The socket factory for a protocol {@link org.apache.http.conn.Scheme Scheme} such as "http" or "https" can be looked up in a {@link org.apache.http.conn.SchemeRegistry SchemeRegistry}. Applications without a need for sophisticated connection management can use this layer directly.
On top of that lies the connection management layer. A
{@link org.apache.http.conn.ClientConnectionManager ClientConnectionManager}
internally manages operated connections, but hands out instances of
{@link org.apache.http.conn.ManagedClientConnection ManagedClientConnection}.
This interface abstracts from the underlying socket operations and
provides convenient methods for opening and updating sockets in order
to establish a {@link org.apache.http.conn.HttpRoute route}.
The operator is encapsulated by the connection manager and called
automatically.
Connections obtained from a manager have to be returned after use.
This can be {@link org.apache.http.conn.ConnectionReleaseTrigger triggered}
on various levels, either by releasing the
{@link org.apache.http.conn.ManagedClientConnection
connection}
directly, or by calling a method on an
{@link org.apache.http.conn.BasicManagedEntity entity}
received from the connection, or by closing the
{@link org.apache.http.conn.EofSensorInputStream stream}
from which that entity is being read.
Connection managers will try to keep returned connections alive in
order to re-use them for subsequent requests along the same route.
The managed connection interface and all triggers for connection release
provide methods to enable or disable this behavior.
An {@link org.apache.http.conn.HttpRoute HttpRoute} is the path along which a request has to be sent to the server. The route starts at a local network address and may pass through a proxy before reaching the target. Routes through a proxy can be tunnelled, and a secure protocol (TLS/SSL) might be put on top of the tunnel. The {@link org.apache.http.conn.RouteTracker RouteTracker} helps in tracking the steps for establishing a route, while a {@link org.apache.http.conn.RouteDirector RouteDirector} determines the next step to take.