Android APIs
public class

DefaultClientConnection

extends SocketHttpClientConnection
implements OperatedClientConnection
java.lang.Object
   ↳ org.apache.http.impl.AbstractHttpClientConnection
     ↳ org.apache.http.impl.SocketHttpClientConnection
       ↳ org.apache.http.impl.conn.DefaultClientConnection

Class Overview

Default implementation of an operated client connection.

Summary

Public Constructors
DefaultClientConnection()
Public Methods
void close()
Closes this connection gracefully.
final Socket getSocket()
final HttpHost getTargetHost()
Obtains the target host for this connection.
final boolean isSecure()
Indicates whether this connection is secure.
void openCompleted(boolean secure, HttpParams params)
Signals that the connection has been successfully open.
void opening(Socket sock, HttpHost target)
Signals that this connection is in the process of being open.
HttpResponse receiveResponseHeader()
Receives the request line and headers of the next response available from this connection.
void sendRequestHeader(HttpRequest request)
Sends the request line and all headers over the connection.
void shutdown()
Force-closes this connection.
void update(Socket sock, HttpHost target, boolean secure, HttpParams params)
Updates this connection.
Protected Methods
HttpMessageParser createResponseParser(SessionInputBuffer buffer, HttpResponseFactory responseFactory, HttpParams params)
SessionInputBuffer createSessionInputBuffer(Socket socket, int buffersize, HttpParams params)
SessionOutputBuffer createSessionOutputBuffer(Socket socket, int buffersize, HttpParams params)
[Expand]
Inherited Methods
From class org.apache.http.impl.SocketHttpClientConnection
From class org.apache.http.impl.AbstractHttpClientConnection
From class java.lang.Object
From interface org.apache.http.HttpInetConnection
From interface org.apache.http.HttpClientConnection
From interface org.apache.http.conn.OperatedClientConnection
From interface org.apache.http.HttpConnection

Public Constructors

public DefaultClientConnection ()

Added in API level 1

Public Methods

public void close ()

Added in API level 1

Closes this connection gracefully. This method will attempt to flush the transmitter's internal buffer prior to closing the underlying socket. This method MUST NOT be called from a different thread to force shutdown of the connection. Use shutdown instead.

Throws
IOException

public final Socket getSocket ()

Added in API level 1

public final HttpHost getTargetHost ()

Added in API level 1

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

Added in API level 1

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 openCompleted (boolean secure, HttpParams params)

Added in API level 1

Signals that the connection has been successfully open. An attempt to call this method on an open connection will cause an exception.

Parameters
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.
Throws
IOException

public void opening (Socket sock, HttpHost target)

Added in API level 1

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 before openCompleted(boolean, HttpParams) is called. 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.
You also must call openCompleted(boolean, 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

public HttpResponse receiveResponseHeader ()

Added in API level 1

Receives 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.

Returns
  • a new HttpResponse object with status line and headers initialized.

public void sendRequestHeader (HttpRequest request)

Added in API level 1

Sends the request line and all headers over the connection.

Parameters
request the request whose headers to send.

public void shutdown ()

Added in API level 1

Force-closes this connection. If the connection is still in the process of being open (the method opening was already called but openCompleted was 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.

Throws
IOException in case of a problem

public void update (Socket sock, HttpHost target, boolean secure, HttpParams params)

Added in API level 1

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
Throws
IOException

Protected Methods

protected HttpMessageParser createResponseParser (SessionInputBuffer buffer, HttpResponseFactory responseFactory, HttpParams params)

Added in API level 1

protected SessionInputBuffer createSessionInputBuffer (Socket socket, int buffersize, HttpParams params)

Added in API level 1

Throws
IOException

protected SessionOutputBuffer createSessionOutputBuffer (Socket socket, int buffersize, HttpParams params)

Added in API level 1

Throws
IOException