Top Description Fields Constructors Methods
org.apache.http.impl

public abstract Class AbstractHttpClientConnection

extends Object
implements HttpClientConnection
Class Inheritance
All Implemented Interfaces
org.apache.http.HttpClientConnection, org.apache.http.HttpConnection, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.apache.http.impl.SocketHttpClientConnection
Annotations
@Deprecated
Imports
java.io.IOException, java.net.SocketTimeoutException, org.apache.http.HttpClientConnection, .HttpConnectionMetrics, .HttpEntity, .HttpEntityEnclosingRequest, .HttpException, .HttpRequest, .HttpResponse, .HttpResponseFactory, .HttpStatus, org.apache.http.impl.entity.EntityDeserializer, .EntitySerializer, .LaxContentLengthStrategy, .StrictContentLengthStrategy, org.apache.http.impl.io.DefaultHttpResponseParser, .HttpRequestWriter, org.apache.http.io.EofSensor, .HttpMessageParser, .HttpMessageWriter, .HttpTransportMetrics, .SessionInputBuffer, .SessionOutputBuffer, org.apache.http.params.HttpParams, org.apache.http.util.Args

Deprecated

(4.3) use DefaultBHttpClientConnection

Abstract client-side HTTP connection capable of transmitting and receiving data using arbitrary SessionInputBuffer and SessionOutputBuffer implementations.

The following parameters can be used to customize the behavior of this class:

Since
4.0

Field Summary

Modifier and TypeField and Description
private final EntityDeserializer
entitydeserializer

Deprecated as a consequence of EntityDeserializer being deprecated.
private final EntitySerializer
entityserializer

Deprecated as a consequence of EntitySerializer being deprecated.
private EofSensor
eofSensor

Deprecated as a consequence of EofSensor being deprecated.
private SessionInputBuffer
private HttpConnectionMetricsImpl
private SessionOutputBuffer
private HttpMessageWriter<HttpRequest>
private HttpMessageParser<HttpResponse>

Constructor Summary

AccessConstructor and Description
public
AbstractHttpClientConnection()

Creates an instance of this class.

Method Summary

Modifier and TypeMethod and Description
protected abstract void
assertOpen()

Asserts if the connection is open.

protected HttpConnectionMetricsImpl
createConnectionMetrics(final HttpTransportMetrics inTransportMetric, final HttpTransportMetrics outTransportMetric)

protected EntityDeserializer

Returns:

HTTP entity deserializer
createEntityDeserializer
()

Deprecated as a consequence of EntityDeserializer being deprecated.
Creates an instance of EntityDeserializer with the LaxContentLengthStrategy implementation to be used for de-serializing entities received over this connection.
protected EntitySerializer

Returns:

HTTP entity serialzier.
createEntitySerializer
()

Deprecated as a consequence of EntitySerializer being deprecated.
Creates an instance of EntitySerializer with the StrictContentLengthStrategy implementation to be used for serializing HTTP entities sent over this connection.
protected HttpResponseFactory

Returns:

HTTP response factory.
createHttpResponseFactory
()

Creates an instance of DefaultHttpResponseFactory to be used for creating HttpResponse objects received by over this connection.

protected HttpMessageWriter<HttpRequest>

Returns:

HTTP message writer
createRequestWriter
(final SessionOutputBuffer
the session output buffer
buffer
,
final HttpParams
HTTP parameters
params
)

Deprecated as a consequence of HttpParams being deprecated.
Creates an instance of HttpMessageWriter to be used for writing out HTTP requests sent over this connection.
protected HttpMessageParser<HttpResponse>

Returns:

HTTP message parser.
createResponseParser
(final SessionInputBuffer
the session input buffer.
buffer
,
final HttpResponseFactory
the HTTP response factory.
responseFactory
,
final HttpParams
HTTP parameters.
params
)

Deprecated as a consequence of HttpParams being deprecated.
Creates an instance of HttpMessageParser to be used for parsing HTTP responses received over this connection.
protected void
public void
flush()

Implements org.apache.http.HttpClientConnection.flush.

Writes out all pending buffered data over the open connection.
public HttpConnectionMetrics
getMetrics()

Implements org.apache.http.HttpConnection.getMetrics.

Returns a collection of connection metrics.
protected void
init(final SessionInputBuffer
the session input buffer.
sessionInputBuffer
,
final SessionOutputBuffer
the session output buffer.
sessionOutputBuffer
,
final HttpParams
HTTP parameters.
params
)

Deprecated as a consequence of HttpParams being deprecated.
Initializes this connection object with SessionInputBuffer and SessionOutputBuffer instances to be used for sending and receiving data.
protected boolean
public boolean
isResponseAvailable(final int
the maximum time in milliseconds to wait for data
timeout
)

Implements org.apache.http.HttpClientConnection.isResponseAvailable.

Checks if response data is available from the connection.
public boolean
isStale()

Implements org.apache.http.HttpConnection.isStale.

Checks whether this connection has gone down.
public void
receiveResponseEntity(final HttpResponse
the response to attach the entity to
response
)

Implements org.apache.http.HttpClientConnection.receiveResponseEntity.

Receives the next response entity available from this connection and attaches it to an existing HttpResponse object.
public HttpResponse
receiveResponseHeader()

Implements org.apache.http.HttpClientConnection.receiveResponseHeader.

Receives the request line and headers of the next response available from this connection.
public void
sendRequestEntity(final HttpEntityEnclosingRequest
the request whose entity to send.
request
)

Implements org.apache.http.HttpClientConnection.sendRequestEntity.

Sends the request entity over the connection.
public void
sendRequestHeader(final HttpRequest
the request whose headers to send.
request
)

Implements org.apache.http.HttpClientConnection.sendRequestHeader.

Sends the request line and all headers over the connection.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entitydeserializerback to summary
private final EntityDeserializer entitydeserializer

Deprecated

as a consequence of EntityDeserializer being deprecated. See corresponding docs for further information.

entityserializerback to summary
private final EntitySerializer entityserializer

Deprecated

as a consequence of EntitySerializer being deprecated. See corresponding docs for further information.

eofSensorback to summary
private EofSensor eofSensor

Deprecated

as a consequence of EofSensor being deprecated. See corresponding docs for further information.

inBufferback to summary
private SessionInputBuffer inBuffer
metricsback to summary
private HttpConnectionMetricsImpl metrics
outbufferback to summary
private SessionOutputBuffer outbuffer
requestWriterback to summary
private HttpMessageWriter<HttpRequest> requestWriter
responseParserback to summary
private HttpMessageParser<HttpResponse> responseParser

Constructor Detail

AbstractHttpClientConnectionback to summary
public AbstractHttpClientConnection()

Creates an instance of this class.

This constructor will invoke createEntityDeserializer() and createEntitySerializer() methods in order to initialize HTTP entity serializer and deserializer implementations for this connection.

Method Detail

assertOpenback to summary
protected abstract void assertOpen() throws IllegalStateException

Asserts if the connection is open.

Exceptions
IllegalStateException:
if the connection is not open.
createConnectionMetricsback to summary
protected HttpConnectionMetricsImpl createConnectionMetrics(final HttpTransportMetrics inTransportMetric, final HttpTransportMetrics outTransportMetric)
Since
4.1
createEntityDeserializerback to summary
protected EntityDeserializer createEntityDeserializer()

Deprecated

as a consequence of EntityDeserializer being deprecated. See corresponding docs for further information.

Creates an instance of EntityDeserializer with the LaxContentLengthStrategy implementation to be used for de-serializing entities received over this connection.

This method can be overridden in a super class in order to create instances of EntityDeserializer using a custom org.apache.http.entity.ContentLengthStrategy.

Returns:EntityDeserializer

HTTP entity deserializer

createEntitySerializerback to summary
protected EntitySerializer createEntitySerializer()

Deprecated

as a consequence of EntitySerializer being deprecated. See corresponding docs for further information.

Creates an instance of EntitySerializer with the StrictContentLengthStrategy implementation to be used for serializing HTTP entities sent over this connection.

This method can be overridden in a super class in order to create instances of EntitySerializer using a custom org.apache.http.entity.ContentLengthStrategy.

Returns:EntitySerializer

HTTP entity serialzier.

createHttpResponseFactoryback to summary
protected HttpResponseFactory createHttpResponseFactory()

Creates an instance of DefaultHttpResponseFactory to be used for creating HttpResponse objects received by over this connection.

This method can be overridden in a super class in order to provide a different implementation of the HttpResponseFactory interface.

Returns:HttpResponseFactory

HTTP response factory.

createRequestWriterback to summary
protected HttpMessageWriter<HttpRequest> createRequestWriter(final SessionOutputBuffer buffer, final HttpParams params)

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Creates an instance of HttpMessageWriter to be used for writing out HTTP requests sent over this connection.

This method can be overridden in a super class in order to provide a different implementation of the HttpMessageWriter interface or to pass a different implementation of org.apache.http.message.LineFormatter to the the default implementation HttpRequestWriter.

Parameters
buffer:SessionOutputBuffer

the session output buffer

params:HttpParams

HTTP parameters

Returns:HttpMessageWriter<HttpRequest>

HTTP message writer

createResponseParserback to summary
protected HttpMessageParser<HttpResponse> createResponseParser(final SessionInputBuffer buffer, final HttpResponseFactory responseFactory, final HttpParams params)

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Creates an instance of HttpMessageParser to be used for parsing HTTP responses received over this connection.

This method can be overridden in a super class in order to provide a different implementation of the HttpMessageParser interface or to pass a different implementation of the org.apache.http.message.LineParser to the the DefaultHttpResponseParser constructor.

Parameters
buffer:SessionInputBuffer

the session input buffer.

responseFactory:HttpResponseFactory

the HTTP response factory.

params:HttpParams

HTTP parameters.

Returns:HttpMessageParser<HttpResponse>

HTTP message parser.

doFlushback to summary
protected void doFlush() throws IOException
flushback to summary
public void flush() throws IOException

Implements org.apache.http.HttpClientConnection.flush.

Doc from org.apache.http.HttpClientConnection.flush.

Writes out all pending buffered data over the open connection.

Annotations
@Override
Exceptions
IOException:
in case of an I/O error
getMetricsback to summary
public HttpConnectionMetrics getMetrics()

Implements org.apache.http.HttpConnection.getMetrics.

Doc from org.apache.http.HttpConnection.getMetrics.

Returns a collection of connection metrics.

Returns:HttpConnectionMetrics

HttpConnectionMetrics

Annotations
@Override
initback to summary
protected void init(final SessionInputBuffer sessionInputBuffer, final SessionOutputBuffer sessionOutputBuffer, final HttpParams params)

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Initializes this connection object with SessionInputBuffer and SessionOutputBuffer instances to be used for sending and receiving data. These session buffers can be bound to any arbitrary physical output medium.

This method will invoke createHttpResponseFactory(), createRequestWriter(SessionOutputBuffer, HttpParams) and createResponseParser(SessionInputBuffer, HttpResponseFactory, HttpParams) methods to initialize HTTP request writer and response parser for this connection.

Parameters
sessionInputBuffer:SessionInputBuffer

the session input buffer.

sessionOutputBuffer:SessionOutputBuffer

the session output buffer.

params:HttpParams

HTTP parameters.

isEofback to summary
protected boolean isEof()
isResponseAvailableback to summary
public boolean isResponseAvailable(final int timeout) throws IOException

Implements org.apache.http.HttpClientConnection.isResponseAvailable.

Doc from org.apache.http.HttpClientConnection.isResponseAvailable.

Checks if response data is available from the connection. May wait for the specified time until some data becomes available. Note that some implementations may completely ignore the timeout parameter.

Parameters
timeout:int

the maximum time in milliseconds to wait for data

Returns:boolean

true if data is available; false if there was no data available even after waiting for timeout milliseconds.

Annotations
@Override
Exceptions
IOException:
if an error happens on the connection
isStaleback to summary
public boolean isStale()

Implements org.apache.http.HttpConnection.isStale.

Doc from org.apache.http.HttpConnection.isStale.

Checks whether this connection has gone down. Network connections may get closed during some time of inactivity for several reasons. The next time a read is attempted on such a connection it will throw an IOException. This method tries to alleviate this inconvenience by trying to find out if a connection is still usable. Implementations may do that by attempting a read with a very small timeout. Thus this method may block for a small amount of time before returning a result. It is therefore an expensive operation.

Returns:boolean

true if attempts to use this connection are likely to succeed, or false if they are likely to fail and this connection should be closed

Annotations
@Override
receiveResponseEntityback to summary
public void receiveResponseEntity(final HttpResponse response) throws HttpException, IOException

Implements org.apache.http.HttpClientConnection.receiveResponseEntity.

Doc from org.apache.http.HttpClientConnection.receiveResponseEntity.

Receives the next response entity available from this connection and attaches it to an existing HttpResponse object.

Parameters
response:HttpResponse

the response to attach the entity to

Annotations
@Override
Exceptions
HttpException:
in case of HTTP protocol violation
IOException:
in case of an I/O error
receiveResponseHeaderback to summary
public HttpResponse receiveResponseHeader() throws HttpException, IOException

Implements org.apache.http.HttpClientConnection.receiveResponseHeader.

Doc from org.apache.http.HttpClientConnection.receiveResponseHeader.

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:HttpResponse

a new HttpResponse object with status line and headers initialized.

Annotations
@Override
Exceptions
HttpException:
in case of HTTP protocol violation
IOException:
in case of an I/O error
sendRequestEntityback to summary
public void sendRequestEntity(final HttpEntityEnclosingRequest request) throws HttpException, IOException

Implements org.apache.http.HttpClientConnection.sendRequestEntity.

Doc from org.apache.http.HttpClientConnection.sendRequestEntity.

Sends the request entity over the connection.

Parameters
request:HttpEntityEnclosingRequest

the request whose entity to send.

Annotations
@Override
Exceptions
HttpException:
in case of HTTP protocol violation
IOException:
in case of an I/O error
sendRequestHeaderback to summary
public void sendRequestHeader(final HttpRequest request) throws HttpException, IOException

Implements org.apache.http.HttpClientConnection.sendRequestHeader.

Doc from org.apache.http.HttpClientConnection.sendRequestHeader.

Sends the request line and all headers over the connection.

Parameters
request:HttpRequest

the request whose headers to send.

Annotations
@Override
Exceptions
HttpException:
in case of HTTP protocol violation
IOException:
in case of an I/O error