Top Description Fields Constructors Methods
org.apache.hc.core5.http.impl.io

public Class DefaultBHttpServerConnection

extends BHttpConnectionBase
implements HttpServerConnection
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.io.HttpServerConnection, org.apache.hc.core5.http.io.BHttpConnection, org.apache.hc.core5.http.HttpConnection, org.apache.hc.core5.http.SocketModalCloseable, org.apache.hc.core5.io.ModalCloseable, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, .OutputStream, java.net.Socket, java.nio.charset.CharsetDecoder, .CharsetEncoder, org.apache.hc.core5.http.ClassicHttpRequest, .ClassicHttpResponse, .ContentLengthStrategy, .HttpEntity, .HttpException, .HttpStatus, .HttpVersion, .ProtocolVersion, .UnsupportedHttpVersionException, org.apache.hc.core5.http.config.Http1Config, org.apache.hc.core5.http.impl.DefaultContentLengthStrategy, org.apache.hc.core5.http.io.HttpMessageParser, .HttpMessageParserFactory, .HttpMessageWriter, .HttpMessageWriterFactory, .HttpServerConnection, org.apache.hc.core5.util.Args

Default implementation of HttpServerConnection.
Since
4.3

Field Summary

Modifier and TypeField and Description
private final ContentLengthStrategy
private final ContentLengthStrategy
private final HttpMessageParser<ClassicHttpRequest>
private final HttpMessageWriter<ClassicHttpResponse>
private final String
Inherited from org.apache.hc.core5.http.impl.io.BHttpConnectionBase:
connMetricsendpointDetailshttp1ConfiginBufferoutbuffersocketHolderRefversion

Constructor Summary

AccessConstructor and Description
public
DefaultBHttpServerConnection(final String
protocol scheme
scheme
,
final Http1Config
Message http1Config. If null Http1Config#DEFAULT will be used.
http1Config
,
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 ContentLengthStrategy
incoming content length strategy. If null DefaultContentLengthStrategy#INSTANCE will be used.
incomingContentStrategy
,
final ContentLengthStrategy
outgoing content length strategy. If null DefaultContentLengthStrategy#INSTANCE will be used.
outgoingContentStrategy
,
final HttpMessageParserFactory<ClassicHttpRequest>
request parser factory. If null DefaultHttpRequestParserFactory#INSTANCE will be used.
requestParserFactory
,
final HttpMessageWriterFactory<ClassicHttpResponse>
response writer factory. If null DefaultHttpResponseWriterFactory#INSTANCE will be used.
responseWriterFactory
)

Creates new instance of DefaultBHttpServerConnection.

public
DefaultBHttpServerConnection(final String scheme, final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder)

public
DefaultBHttpServerConnection(final String scheme, final Http1Config http1Config)

Method Summary

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

Overrides org.apache.hc.core5.http.impl.io.BHttpConnectionBase.bind.

Binds this connection to the given Socket.
protected void
protected void
public void
receiveRequestEntity(final ClassicHttpRequest
the request to attach the entity to.
request
)

Implements org.apache.hc.core5.http.io.HttpServerConnection.receiveRequestEntity.

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

Implements org.apache.hc.core5.http.io.HttpServerConnection.receiveRequestHeader.

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

Implements org.apache.hc.core5.http.io.HttpServerConnection.sendResponseEntity.

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

Implements org.apache.hc.core5.http.io.HttpServerConnection.sendResponseHeader.

Sends the response line and headers of a response over this connection.
Inherited from org.apache.hc.core5.http.impl.io.BHttpConnectionBase:
awaitInputbindcloseclosecreateContentInputStreamcreateContentOutputStreamcreateIncomingEntityensureOpenflushgetEndpointDetailsgetLocalAddressgetProtocolVersiongetRemoteAddressgetSocketHoldergetSocketTimeoutgetSSLSessionincrementRequestCountincrementResponseCountisDataAvailableisOpenisStalesetSocketTimeouttoString

Field Detail

incomingContentStrategyback to summary
private final ContentLengthStrategy incomingContentStrategy
outgoingContentStrategyback to summary
private final ContentLengthStrategy outgoingContentStrategy
requestParserback to summary
private final HttpMessageParser<ClassicHttpRequest> requestParser
responseWriterback to summary
private final HttpMessageWriter<ClassicHttpResponse> responseWriter
schemeback to summary
private final String scheme

Constructor Detail

DefaultBHttpServerConnectionback to summary
public DefaultBHttpServerConnection(final String scheme, final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder, final ContentLengthStrategy incomingContentStrategy, final ContentLengthStrategy outgoingContentStrategy, final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory, final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory)

Creates new instance of DefaultBHttpServerConnection.

Parameters
scheme:String

protocol scheme

http1Config:Http1Config

Message http1Config. If null Http1Config#DEFAULT will be used.

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.

incomingContentStrategy:ContentLengthStrategy

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

outgoingContentStrategy:ContentLengthStrategy

outgoing content length strategy. If null DefaultContentLengthStrategy#INSTANCE will be used.

requestParserFactory:HttpMessageParserFactory<ClassicHttpRequest>

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

responseWriterFactory:HttpMessageWriterFactory<ClassicHttpResponse>

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

DefaultBHttpServerConnectionback to summary
public DefaultBHttpServerConnection(final String scheme, final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder)
DefaultBHttpServerConnectionback to summary
public DefaultBHttpServerConnection(final String scheme, final Http1Config http1Config)

Method Detail

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

Overrides org.apache.hc.core5.http.impl.io.BHttpConnectionBase.bind.

Doc from org.apache.hc.core5.http.impl.io.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.
onRequestReceivedback to summary
protected void onRequestReceived(final ClassicHttpRequest request)
onResponseSubmittedback to summary
protected void onResponseSubmitted(final ClassicHttpResponse response)
receiveRequestEntityback to summary
public void receiveRequestEntity(final ClassicHttpRequest request) throws HttpException, IOException

Implements org.apache.hc.core5.http.io.HttpServerConnection.receiveRequestEntity.

Doc from org.apache.hc.core5.http.io.HttpServerConnection.receiveRequestEntity.

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

Parameters
request:ClassicHttpRequest

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 ClassicHttpRequest receiveRequestHeader() throws HttpException, IOException

Implements org.apache.hc.core5.http.io.HttpServerConnection.receiveRequestHeader.

Doc from org.apache.hc.core5.http.io.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:ClassicHttpRequest

a new HttpRequest object whose request line and headers are initialized or null if the connection has been closed by the opposite endpoint.

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 ClassicHttpResponse response) throws HttpException, IOException

Implements org.apache.hc.core5.http.io.HttpServerConnection.sendResponseEntity.

Doc from org.apache.hc.core5.http.io.HttpServerConnection.sendResponseEntity.

Sends the response entity of a response over this connection.

Parameters
response:ClassicHttpResponse

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 ClassicHttpResponse response) throws HttpException, IOException

Implements org.apache.hc.core5.http.io.HttpServerConnection.sendResponseHeader.

Doc from org.apache.hc.core5.http.io.HttpServerConnection.sendResponseHeader.

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

Parameters
response:ClassicHttpResponse

the response whose headers to send.

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