Class DefaultClientConnection
- java.lang.Object
-
- org.apache.http.impl.AbstractHttpClientConnection
-
- org.apache.http.impl.SocketHttpClientConnection
-
- org.apache.http.impl.conn.DefaultClientConnection
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ManagedHttpClientConnection,OperatedClientConnection,HttpClientConnection,HttpConnection,HttpInetConnection,HttpContext
@Deprecated public class DefaultClientConnection extends SocketHttpClientConnection implements OperatedClientConnection, ManagedHttpClientConnection, HttpContext
Deprecated.(4.3) useManagedHttpClientConnectionFactory.Default implementation of an operated client connection.- Since:
- 4.0
-
-
Field Summary
-
Fields inherited from interface org.apache.http.protocol.HttpContext
RESERVED_PREFIX
-
-
Constructor Summary
Constructors Constructor Description DefaultClientConnection()Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidbind(java.net.Socket socket)Deprecated.Binds this connection to the given socket.voidclose()Deprecated.Closes this connection gracefully.java.lang.ObjectgetAttribute(java.lang.String id)Deprecated.Obtains attribute with the given name.java.lang.StringgetId()Deprecated.Returns connection ID which is expected to be unique for the life span of the connection manager.java.net.SocketgetSocket()Deprecated.Obtains the socket for this connection.javax.net.ssl.SSLSessiongetSSLSession()Deprecated.Obtains the SSL session of the underlying connection, if any.HttpHostgetTargetHost()Deprecated.Obtains the target host for this connection.booleanisSecure()Deprecated.Indicates whether this connection is secure.voidopenCompleted(boolean secure, HttpParams params)Deprecated.Signals that the connection has been successfully open.voidopening(java.net.Socket sock, HttpHost target)Deprecated.Signals that this connection is in the process of being open.HttpResponsereceiveResponseHeader()Deprecated.Receives the request line and headers of the next response available from this connection.java.lang.ObjectremoveAttribute(java.lang.String id)Deprecated.Removes attribute with the given name from the context.voidsendRequestHeader(HttpRequest request)Deprecated.Sends the request line and all headers over the connection.voidsetAttribute(java.lang.String id, java.lang.Object obj)Deprecated.Sets value of the attribute with the given name.voidshutdown()Deprecated.Force-closes this connection.voidupdate(java.net.Socket sock, HttpHost target, boolean secure, HttpParams params)Deprecated.Updates this connection.-
Methods inherited from class org.apache.http.impl.SocketHttpClientConnection
getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getSocketTimeout, isOpen, setSocketTimeout, toString
-
Methods inherited from class org.apache.http.impl.AbstractHttpClientConnection
flush, getMetrics, isResponseAvailable, isStale, receiveResponseEntity, sendRequestEntity
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.http.HttpClientConnection
flush, isResponseAvailable, receiveResponseEntity, sendRequestEntity
-
Methods inherited from interface org.apache.http.HttpConnection
getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout
-
Methods inherited from interface org.apache.http.HttpInetConnection
getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort
-
-
-
-
Method Detail
-
getId
public java.lang.String getId()
Deprecated.Description copied from interface:ManagedHttpClientConnectionReturns connection ID which is expected to be unique for the life span of the connection manager.- Specified by:
getIdin interfaceManagedHttpClientConnection
-
getTargetHost
public final HttpHost getTargetHost()
Deprecated.Description copied from interface:OperatedClientConnectionObtains 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.- Specified by:
getTargetHostin interfaceOperatedClientConnection- Returns:
- the host to which this connection is opened
-
isSecure
public final boolean isSecure()
Deprecated.Description copied from interface:OperatedClientConnectionIndicates 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.- Specified by:
isSecurein interfaceOperatedClientConnection- Returns:
trueif this connection is secure,falseotherwise
-
getSocket
public final java.net.Socket getSocket()
Deprecated.Description copied from interface:OperatedClientConnectionObtains 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.- Specified by:
getSocketin interfaceManagedHttpClientConnection- Specified by:
getSocketin interfaceOperatedClientConnection- Returns:
- the socket for communicating with the
target host
-
getSSLSession
public javax.net.ssl.SSLSession getSSLSession()
Deprecated.Description copied from interface:ManagedHttpClientConnectionObtains the SSL session of the underlying connection, if any. If this connection is open, and the underlying socket is anSSLSocket, the SSL session of that socket is obtained. This is a potentially blocking operation.- Specified by:
getSSLSessionin interfaceManagedHttpClientConnection- Returns:
- the underlying SSL session if available,
nullotherwise
-
opening
public void opening(java.net.Socket sock, HttpHost target) throws java.io.IOExceptionDeprecated.Description copied from interface:OperatedClientConnectionSignals that this connection is in the process of being open.By calling this method, the connection can be re-initialized with a new Socket instance before
OperatedClientConnection.openCompleted(boolean, org.apache.http.params.HttpParams)is called. This enabled the connection to close that socket ifshutdownis called before it is fully open. Closing an 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.This method can be called multiple times if the connection is layered over another protocol. Note: This method will not close the previously used socket. It is the caller's responsibility to close that socket if it is no longer required.
The caller must invoke
OperatedClientConnection.openCompleted(boolean, org.apache.http.params.HttpParams)in order to complete the process.- Specified by:
openingin interfaceOperatedClientConnection- Parameters:
sock- the unconnected socket which is about to be connected.target- the target host of this connection- Throws:
java.io.IOException
-
openCompleted
public void openCompleted(boolean secure, HttpParams params) throws java.io.IOExceptionDeprecated.Description copied from interface:OperatedClientConnectionSignals that the connection has been successfully open. An attempt to call this method on an open connection will cause an exception.- Specified by:
openCompletedin interfaceOperatedClientConnection- 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:
java.io.IOException
-
shutdown
public void shutdown() throws java.io.IOExceptionDeprecated.Force-closes this connection. If the connection is still in the process of being open (the methodopeningwas already called butopenCompletedwas not), the associated socket that is being connected to a remote address will be closed. That will interrupt a thread that is blocked on connecting the socket. If the connection is not yet open, this will prevent the connection from being opened.- Specified by:
shutdownin interfaceHttpConnection- Overrides:
shutdownin classSocketHttpClientConnection- Throws:
java.io.IOException- in case of a problem
-
close
public void close() throws java.io.IOExceptionDeprecated.Description copied from interface:HttpConnectionCloses this connection gracefully. This method will attempt to flush the internal output buffer prior to closing the underlying socket. This method MUST NOT be called from a different thread to force shutdown of the connection. Useshutdowninstead.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceHttpConnection- Overrides:
closein classSocketHttpClientConnection- Throws:
java.io.IOException
-
bind
public void bind(java.net.Socket socket) throws java.io.IOExceptionDeprecated.Description copied from interface:ManagedHttpClientConnectionBinds this connection to the given socket. The connection is considered open if it is bound and the underlying socket is connection to a remote host.- Specified by:
bindin interfaceManagedHttpClientConnection- Parameters:
socket- the socket to bind the connection to.- Throws:
java.io.IOException
-
update
public void update(java.net.Socket sock, HttpHost target, boolean secure, HttpParams params) throws java.io.IOExceptionDeprecated.Description copied from interface:OperatedClientConnectionUpdates 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.
- Specified by:
updatein interfaceOperatedClientConnection- 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:
java.io.IOException
-
receiveResponseHeader
public HttpResponse receiveResponseHeader() throws HttpException, java.io.IOException
Deprecated.Description copied from interface:HttpClientConnectionReceives the request line and headers of the next response available from this connection. The caller should examine the HttpResponse object to find out if it should try to receive a response entity as well.- Specified by:
receiveResponseHeaderin interfaceHttpClientConnection- Overrides:
receiveResponseHeaderin classAbstractHttpClientConnection- Returns:
- a new HttpResponse object with status line and headers initialized.
- Throws:
HttpException- in case of HTTP protocol violationjava.io.IOException- in case of an I/O error
-
sendRequestHeader
public void sendRequestHeader(HttpRequest request) throws HttpException, java.io.IOException
Deprecated.Description copied from interface:HttpClientConnectionSends the request line and all headers over the connection.- Specified by:
sendRequestHeaderin interfaceHttpClientConnection- Overrides:
sendRequestHeaderin classAbstractHttpClientConnection- Parameters:
request- the request whose headers to send.- Throws:
HttpException- in case of HTTP protocol violationjava.io.IOException- in case of an I/O error
-
getAttribute
public java.lang.Object getAttribute(java.lang.String id)
Deprecated.Description copied from interface:HttpContextObtains attribute with the given name.- Specified by:
getAttributein interfaceHttpContext- Parameters:
id- the attribute name.- Returns:
- attribute value, or
nullif not set.
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String id)
Deprecated.Description copied from interface:HttpContextRemoves attribute with the given name from the context.- Specified by:
removeAttributein interfaceHttpContext- Parameters:
id- the attribute name.- Returns:
- attribute value, or
nullif not set.
-
setAttribute
public void setAttribute(java.lang.String id, java.lang.Object obj)Deprecated.Description copied from interface:HttpContextSets value of the attribute with the given name.- Specified by:
setAttributein interfaceHttpContext- Parameters:
id- the attribute name.obj- the attribute value.
-
-