org.apache.http.conn.OperatedClientConnection
A client-side connection that needs to be operated.
It relies on outside logic to connect sockets to the appropriate hosts.
It can be operated directly by an application, or through an
operator.
Known Indirect Subclasses
Summary
Details
Public Methods
public
void
announce(Socket sock)
Announces opening of this connection.
Opening can be announced only while the connection is closed.
This is an optional step, you can call
open
without an announcement.
By calling this method, you provide the connection with
the unconnected socket that will be connected in order
to call
open. This allows the connection to
close that socket if
shutdown
is called before it is open. Closing the unconnected socket
will interrupt a thread that is blocked on the connect.
Otherwise, that thread will either time out on the connect,
or it returns successfully and then opens this connection
which was just shut down.
Note:
The result of
getSocket is defined
only for open connections. You MUST NOT rely on that
method to return the unconnected socket after announcing.
Parameters
| sock
| the unconnected socket which is about to
be connected in order to call open.
null can be passed to undo a
previous call.
|
public
Socket
getSocket()
Obtains the socket for this connection.
The return value is well-defined only while the connection is open.
It may change even while the connection is open,
because of an
update.
public
HttpHost
getTargetHost()
Obtains the target host for this connection.
If the connection is to a proxy but not tunnelled, this is
the proxy. If the connection is tunnelled through a proxy,
this is the target of the tunnel.
The return value is well-defined only while the connection is open.
It may change even while the connection is open,
because of an
update.
Returns
- the host to which this connection is opened
public
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,
because of an
update.
Returns
true if this connection is secure,
false otherwise
public
void
open(Socket sock, HttpHost target, boolean secure, HttpParams params)
Opens this connection.
A connection can be openend only while it is closed.
To modify a connection while it is open, use
update.
Parameters
| sock
| the open socket for communicating with the target host |
| target
| the target host of this connection |
| secure
| true if this connection is secure, for
example if an SSLSocket is used, or
false if it is not secure |
| params
| parameters for this connection. The parameters will
be used when creating dependent objects, for example
to determine buffer sizes.
|
public
void
update(Socket sock, HttpHost target, boolean secure, HttpParams params)
Updates this connection.
A connection can be updated only while it is open.
Updates are used for example when a tunnel has been established,
or when a TLS/SSL connection has been layered on top of a plain
socket connection.
Note: Updating the connection will
not close the
previously used socket. It is the caller's responsibility to close
that socket if it is no longer required.
Parameters
| sock
| the new socket for communicating with the target host,
or null to continue using the old socket.
If null is passed, helper objects that
depend on the socket should be re-used. In that case,
some changes in the parameters will not take effect. |
| target
| the new target host of this connection |
| secure
| true if this connection is now secure,
false if it is not secure |
| params
| new parameters for this connection
|