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

public abstract Class AbstractHttpServerConnection

extends Object
implements HttpServerConnection
Class Inheritance
All Implemented Interfaces
org.apache.http.HttpServerConnection, org.apache.http.HttpConnection, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.apache.http.impl.SocketHttpServerConnection
Annotations
@Deprecated
Imports
java.io.IOException, org.apache.http.HttpConnectionMetrics, .HttpEntity, .HttpEntityEnclosingRequest, .HttpException, .HttpRequest, .HttpRequestFactory, .HttpResponse, .HttpServerConnection, org.apache.http.impl.entity.DisallowIdentityContentLengthStrategy, .EntityDeserializer, .EntitySerializer, .LaxContentLengthStrategy, .StrictContentLengthStrategy, org.apache.http.impl.io.DefaultHttpRequestParser, .HttpResponseWriter, org.apache.http.io.EofSensor, .HttpMessageParser, .HttpMessageWriter, .HttpTransportMetrics, .SessionInputBuffer, .SessionOutputBuffer, org.apache.http.params.HttpParams, org.apache.http.util.Args

Deprecated

(4.3) use DefaultBHttpServerConnection

Abstract server-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 HttpMessageParser<HttpRequest>
private HttpMessageWriter<HttpResponse>

Constructor Summary

AccessConstructor and Description
public
AbstractHttpServerConnection()

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 HttpRequestFactory

Returns:

HTTP request factory.
createHttpRequestFactory
()

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

protected HttpMessageParser<HttpRequest>

Returns:

HTTP message parser.
createRequestParser
(final SessionInputBuffer
the session input buffer.
buffer
,
final HttpRequestFactory
the HTTP request factory.
requestFactory
,
final HttpParams
HTTP parameters.
params
)

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

Returns:

HTTP message writer
createResponseWriter
(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 responses sent over this connection.
protected void
public void
flush()

Implements org.apache.http.HttpServerConnection.flush.

Sends all pending buffered data over this 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.
inBuffer
,
final SessionOutputBuffer
the session output buffer.
outbuffer
,
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
isStale()

Implements org.apache.http.HttpConnection.isStale.

Checks whether this connection has gone down.
public void
receiveRequestEntity(final HttpEntityEnclosingRequest
the request to attach the entity to.
request
)

Implements org.apache.http.HttpServerConnection.receiveRequestEntity.

Receives the next request entity available from this connection and attaches it to an existing request.
public HttpRequest
receiveRequestHeader()

Implements org.apache.http.HttpServerConnection.receiveRequestHeader.

Receives the request line and all headers available from this connection.
public void
sendResponseEntity(final HttpResponse
the response whose entity to send.
response
)

Implements org.apache.http.HttpServerConnection.sendResponseEntity.

Sends the response entity of a response over this connection.
public void
sendResponseHeader(final HttpResponse
the response whose headers to send.
response
)

Implements org.apache.http.HttpServerConnection.sendResponseHeader.

Sends the response line and headers of a response over this 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
requestParserback to summary
private HttpMessageParser<HttpRequest> requestParser
responseWriterback to summary
private HttpMessageWriter<HttpResponse> responseWriter

Constructor Detail

AbstractHttpServerConnectionback to summary
public AbstractHttpServerConnection()

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.

createHttpRequestFactoryback to summary
protected HttpRequestFactory createHttpRequestFactory()

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

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

Returns:HttpRequestFactory

HTTP request factory.

createRequestParserback to summary
protected HttpMessageParser<HttpRequest> createRequestParser(final SessionInputBuffer buffer, final HttpRequestFactory requestFactory, 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 requests 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 DefaultHttpRequestParser constructor.

Parameters
buffer:SessionInputBuffer

the session input buffer.

requestFactory:HttpRequestFactory

the HTTP request factory.

params:HttpParams

HTTP parameters.

Returns:HttpMessageParser<HttpRequest>

HTTP message parser.

createResponseWriterback to summary
protected HttpMessageWriter<HttpResponse> createResponseWriter(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 responses 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 HttpResponseWriter.

Parameters
buffer:SessionOutputBuffer

the session output buffer

params:HttpParams

HTTP parameters

Returns:HttpMessageWriter<HttpResponse>

HTTP message writer

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

Implements org.apache.http.HttpServerConnection.flush.

Doc from org.apache.http.HttpServerConnection.flush.

Sends all pending buffered data over this 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 inBuffer, final SessionOutputBuffer outbuffer, 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 createHttpRequestFactory, createRequestParser(SessionInputBuffer, HttpRequestFactory, HttpParams) and createResponseWriter(SessionOutputBuffer, HttpParams) methods to initialize HTTP request parser and response writer for this connection.

Parameters
inBuffer:SessionInputBuffer

the session input buffer.

outbuffer:SessionOutputBuffer

the session output buffer.

params:HttpParams

HTTP parameters.

isEofback to summary
protected boolean isEof()
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
receiveRequestEntityback to summary
public void receiveRequestEntity(final HttpEntityEnclosingRequest request) throws HttpException, IOException

Implements org.apache.http.HttpServerConnection.receiveRequestEntity.

Doc from org.apache.http.HttpServerConnection.receiveRequestEntity.

Receives the next request entity available from this connection and attaches it to an existing request.

Parameters
request:HttpEntityEnclosingRequest

the request to attach the entity to.

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

Implements org.apache.http.HttpServerConnection.receiveRequestHeader.

Doc from org.apache.http.HttpServerConnection.receiveRequestHeader.

Receives the request line and all headers available from this connection. The caller should examine the returned request and decide if to receive a request entity as well.

Returns:HttpRequest

a new HttpRequest object whose request line and headers are initialized.

Annotations
@Override
Exceptions
HttpException:
in case of HTTP protocol violation
IOException:
in case of an I/O error
sendResponseEntityback to summary
public void sendResponseEntity(final HttpResponse response) throws HttpException, IOException

Implements org.apache.http.HttpServerConnection.sendResponseEntity.

Doc from org.apache.http.HttpServerConnection.sendResponseEntity.

Sends the response entity of a response over this connection.

Parameters
response:HttpResponse

the response whose entity to send.

Annotations
@Override
Exceptions
HttpException:
in case of HTTP protocol violation
IOException:
in case of an I/O error
sendResponseHeaderback to summary
public void sendResponseHeader(final HttpResponse response) throws HttpException, IOException

Implements org.apache.http.HttpServerConnection.sendResponseHeader.

Doc from org.apache.http.HttpServerConnection.sendResponseHeader.

Sends the response line and headers of a response over this connection.

Parameters
response:HttpResponse

the response whose headers to send.

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