Package org.apache.http.conn
Interface OperatedClientConnection
- All Superinterfaces:
HttpClientConnection,HttpConnection,HttpInetConnection
- All Known Implementing Classes:
DefaultClientConnection
public interface OperatedClientConnection extends HttpClientConnection, HttpInetConnection
A client-side connection that relies on outside logic to connect sockets to the
appropriate hosts. It can be operated directly by an application, or through an
operator.- Since:
- 4.0
- Version:
- $Revision: 646087 $ $Date: 2008-04-08 14:36:46 -0700 (Tue, 08 Apr 2008) $
- Author:
- Roland Weber
-
Method Summary
Modifier and Type Method Description SocketgetSocket()Obtains the socket for this connection.HttpHostgetTargetHost()Obtains the target host for this connection.booleanisSecure()Indicates whether this connection is secure.voidopenCompleted(boolean secure, HttpParams params)Signals that the connection has been successfully open.voidopening(Socket sock, HttpHost target)Signals that this connection is in the process of being open.voidupdate(Socket sock, HttpHost target, boolean secure, HttpParams params)Updates this connection.Methods inherited from interface org.apache.http.HttpClientConnection
flush, isResponseAvailable, receiveResponseEntity, receiveResponseHeader, sendRequestEntity, sendRequestHeaderMethods inherited from interface org.apache.http.HttpConnection
close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdownMethods inherited from interface org.apache.http.HttpInetConnection
getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort
-
Method Details
-
getTargetHost
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 anupdate.- Returns:
- the host to which this connection is opened
-
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, because of anupdate.- Returns:
trueif this connection is secure,falseotherwise
-
getSocket
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 anupdate.- Returns:
- the socket for communicating with the
target host
-
opening
Signals that this connection is in the process of being open.
By calling this method, you can provide the connection with the unconnected socket that will be connected beforeopenCompleted(boolean, org.apache.http.params.HttpParams)is called. This allows the connection to close that socket ifshutdownis 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.
You also must callopenCompleted(boolean, org.apache.http.params.HttpParams)in order to complete the process- Parameters:
sock- the unconnected socket which is about to be connected.target- the target host of this connection- Throws:
IOException
-
openCompleted
Signals that the connection has been successfully open. An attempt to call this method on an open connection will cause an exception.- Parameters:
secure-trueif this connection is secure, for example if anSSLSocketis used, orfalseif it is not secureparams- parameters for this connection. The parameters will be used when creating dependent objects, for example to determine buffer sizes.- Throws:
IOException
-
update
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, ornullto continue using the old socket. Ifnullis 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 connectionsecure-trueif this connection is now secure,falseif it is not secureparams- new parameters for this connection- Throws:
IOException
-