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

public Class DefaultBHttpServerConnection

extends BHttpConnectionBase
implements HttpServerConnection
Class Inheritance
All Implemented Interfaces
org.apache.http.HttpServerConnection, org.apache.http.HttpConnection, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, .OutputStream, java.net.Socket, java.nio.charset.CharsetDecoder, .CharsetEncoder, org.apache.http.HttpEntity, .HttpEntityEnclosingRequest, .HttpException, .HttpRequest, .HttpResponse, .HttpServerConnection, org.apache.http.config.MessageConstraints, org.apache.http.entity.ContentLengthStrategy, org.apache.http.impl.entity.DisallowIdentityContentLengthStrategy, org.apache.http.impl.io.DefaultHttpRequestParserFactory, .DefaultHttpResponseWriterFactory, org.apache.http.io.HttpMessageParser, .HttpMessageParserFactory, .HttpMessageWriter, .HttpMessageWriterFactory, org.apache.http.util.Args

Default implementation of HttpServerConnection.
Since
4.3

Field Summary

Modifier and TypeField and Description
private final HttpMessageParser<HttpRequest>
private final HttpMessageWriter<HttpResponse>

Constructor Summary

AccessConstructor and Description
public
DefaultBHttpServerConnection(final int
buffer size. Must be a positive number.
bufferSize
,
final int
fragment size hint.
fragmentSizeHint
,
final CharsetDecoder
decoder to be used for decoding HTTP protocol elements. If null simple type cast will be used for byte to char conversion.
charDecoder
,
final CharsetEncoder
encoder to be used for encoding HTTP protocol elements. If null simple type cast will be used for char to byte conversion.
charEncoder
,
final MessageConstraints
Message constraints. If null MessageConstraints#DEFAULT will be used.
constraints
,
final ContentLengthStrategy
incoming content length strategy. If null DisallowIdentityContentLengthStrategy#INSTANCE will be used.
incomingContentStrategy
,
final ContentLengthStrategy
outgoing content length strategy. If null org.apache.http.impl.entity.StrictContentLengthStrategy#INSTANCE will be used.
outgoingContentStrategy
,
final HttpMessageParserFactory<HttpRequest>
request parser factory. If null DefaultHttpRequestParserFactory#INSTANCE will be used.
requestParserFactory
,
final HttpMessageWriterFactory<HttpResponse>
response writer factory. If null DefaultHttpResponseWriterFactory#INSTANCE will be used.
responseWriterFactory
)

Creates new instance of DefaultBHttpServerConnection.

public
DefaultBHttpServerConnection(final int bufferSize, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder, final MessageConstraints constraints)

public
DefaultBHttpServerConnection(final int bufferSize)

Method Summary

Modifier and TypeMethod and Description
public void
bind(final Socket
the socket.
socket
)

Overrides org.apache.http.impl.BHttpConnectionBase.bind.

Binds this connection to the given Socket.
public void
flush()

Implements org.apache.http.HttpServerConnection.flush.

Sends all pending buffered data over this connection.
protected void
protected void
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 org.apache.http.impl.BHttpConnectionBase:
awaitInputclosecreateInputStreamcreateOutputStreamdoFlushensureOpengetLocalAddressgetLocalPortgetMetricsgetRemoteAddressgetRemotePortgetSessionInputBuffergetSessionOutputBuffergetSocketgetSocketInputStreamgetSocketOutputStreamgetSocketTimeoutincrementRequestCountincrementResponseCountisOpenisStaleprepareInputprepareOutputsetSocketTimeoutshutdowntoString

Field Detail

requestParserback to summary
private final HttpMessageParser<HttpRequest> requestParser
responseWriterback to summary
private final HttpMessageWriter<HttpResponse> responseWriter

Constructor Detail

DefaultBHttpServerConnectionback to summary
public DefaultBHttpServerConnection(final int bufferSize, final int fragmentSizeHint, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder, final MessageConstraints constraints, final ContentLengthStrategy incomingContentStrategy, final ContentLengthStrategy outgoingContentStrategy, final HttpMessageParserFactory<HttpRequest> requestParserFactory, final HttpMessageWriterFactory<HttpResponse> responseWriterFactory)

Creates new instance of DefaultBHttpServerConnection.

Parameters
bufferSize:int

buffer size. Must be a positive number.

fragmentSizeHint:int

fragment size hint.

charDecoder:CharsetDecoder

decoder to be used for decoding HTTP protocol elements. If null simple type cast will be used for byte to char conversion.

charEncoder:CharsetEncoder

encoder to be used for encoding HTTP protocol elements. If null simple type cast will be used for char to byte conversion.

constraints:MessageConstraints

Message constraints. If null MessageConstraints#DEFAULT will be used.

incomingContentStrategy:ContentLengthStrategy

incoming content length strategy. If null DisallowIdentityContentLengthStrategy#INSTANCE will be used.

outgoingContentStrategy:ContentLengthStrategy

outgoing content length strategy. If null org.apache.http.impl.entity.StrictContentLengthStrategy#INSTANCE will be used.

requestParserFactory:HttpMessageParserFactory<HttpRequest>

request parser factory. If null DefaultHttpRequestParserFactory#INSTANCE will be used.

responseWriterFactory:HttpMessageWriterFactory<HttpResponse>

response writer factory. If null DefaultHttpResponseWriterFactory#INSTANCE will be used.

DefaultBHttpServerConnectionback to summary
public DefaultBHttpServerConnection(final int bufferSize, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder, final MessageConstraints constraints)
DefaultBHttpServerConnectionback to summary
public DefaultBHttpServerConnection(final int bufferSize)

Method Detail

bindback to summary
public void bind(final Socket socket) throws IOException

Overrides org.apache.http.impl.BHttpConnectionBase.bind.

Doc from org.apache.http.impl.BHttpConnectionBase.bind.

Binds this connection to the given Socket. This socket will be used by the connection to send and receive data.

After this method's execution the connection status will be reported as open and the isOpen() will return true.

Parameters
socket:Socket

the socket.

Annotations
@Override
Exceptions
IOException:
in case of an I/O error.
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
onRequestReceivedback to summary
protected void onRequestReceived(final HttpRequest request)
onResponseSubmittedback to summary
protected void onResponseSubmitted(final HttpResponse response)
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