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

public Class DefaultBHttpClientConnection

extends BHttpConnectionBase
implements HttpClientConnection
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.io.HttpClientConnection, 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, .InputStream, .OutputStream, java.net.Socket, java.nio.charset.CharsetDecoder, .CharsetEncoder, java.util.Iterator, org.apache.hc.core5.http.ClassicHttpRequest, .ClassicHttpResponse, .ContentLengthStrategy, .HeaderElements, .HttpEntity, .HttpException, .HttpHeaders, .HttpStatus, .HttpVersion, .LengthRequiredException, .NoHttpResponseException, .ProtocolException, .ProtocolVersion, .UnsupportedHttpVersionException, org.apache.hc.core5.http.config.Http1Config, org.apache.hc.core5.http.impl.DefaultContentLengthStrategy, org.apache.hc.core5.http.io.HttpClientConnection, .HttpMessageParser, .HttpMessageParserFactory, .HttpMessageWriter, .HttpMessageWriterFactory, .ResponseOutOfOrderStrategy, org.apache.hc.core5.http.message.BasicTokenIterator, org.apache.hc.core5.util.Args

Default implementation of HttpClientConnection.
Since
4.3

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
DefaultBHttpClientConnection(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 ResponseOutOfOrderStrategy
response out of order strategy. If null NoResponseOutOfOrderStrategy#INSTANCE will be used.
responseOutOfOrderStrategy
,
final HttpMessageWriterFactory<ClassicHttpRequest>
request writer factory. If null DefaultHttpRequestWriterFactory#INSTANCE will be used.
requestWriterFactory
,
final HttpMessageParserFactory<ClassicHttpResponse>
response parser factory. If null DefaultHttpResponseParserFactory#INSTANCE will be used.
responseParserFactory
)

Creates new instance of DefaultBHttpClientConnection.

public
DefaultBHttpClientConnection(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 HttpMessageWriterFactory<ClassicHttpRequest>
request writer factory. If null DefaultHttpRequestWriterFactory#INSTANCE will be used.
requestWriterFactory
,
final HttpMessageParserFactory<ClassicHttpResponse>
response parser factory. If null DefaultHttpResponseParserFactory#INSTANCE will be used.
responseParserFactory
)

Creates new instance of DefaultBHttpClientConnection.

public
DefaultBHttpClientConnection(final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder)

public

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.
public boolean
isConsistent()

Implements org.apache.hc.core5.http.io.HttpClientConnection.isConsistent.

Checks whether this connection is in a consistent state.
protected void
protected void
public void
receiveResponseEntity(final ClassicHttpResponse
the response to attach the entity to
response
)

Implements org.apache.hc.core5.http.io.HttpClientConnection.receiveResponseEntity.

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

Implements org.apache.hc.core5.http.io.HttpClientConnection.receiveResponseHeader.

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

Implements org.apache.hc.core5.http.io.HttpClientConnection.sendRequestEntity.

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

Implements org.apache.hc.core5.http.io.HttpClientConnection.sendRequestHeader.

Sends the request line and all headers over the connection.
public void
terminateRequest(final ClassicHttpRequest
the request to be terminated prematurely.
request
)

Implements org.apache.hc.core5.http.io.HttpClientConnection.terminateRequest.

Terminates request prematurely potentially leaving the connection in a inconsistent state.
Inherited from org.apache.hc.core5.http.impl.io.BHttpConnectionBase:
awaitInputbindcloseclosecreateContentInputStreamcreateContentOutputStreamcreateIncomingEntityensureOpenflushgetEndpointDetailsgetLocalAddressgetProtocolVersiongetRemoteAddressgetSocketHoldergetSocketTimeoutgetSSLSessionincrementRequestCountincrementResponseCountisDataAvailableisOpenisStalesetSocketTimeouttoString

Field Detail

consistentback to summary
private volatile boolean consistent
incomingContentStrategyback to summary
private final ContentLengthStrategy incomingContentStrategy
outgoingContentStrategyback to summary
private final ContentLengthStrategy outgoingContentStrategy
requestWriterback to summary
private final HttpMessageWriter<ClassicHttpRequest> requestWriter
responseOutOfOrderStrategyback to summary
private final ResponseOutOfOrderStrategy responseOutOfOrderStrategy
responseParserback to summary
private final HttpMessageParser<ClassicHttpResponse> responseParser

Constructor Detail

DefaultBHttpClientConnectionback to summary
public DefaultBHttpClientConnection(final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder, final ContentLengthStrategy incomingContentStrategy, final ContentLengthStrategy outgoingContentStrategy, final ResponseOutOfOrderStrategy responseOutOfOrderStrategy, final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory, final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory)

Creates new instance of DefaultBHttpClientConnection.

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

responseOutOfOrderStrategy:ResponseOutOfOrderStrategy

response out of order strategy. If null NoResponseOutOfOrderStrategy#INSTANCE will be used.

requestWriterFactory:HttpMessageWriterFactory<ClassicHttpRequest>

request writer factory. If null DefaultHttpRequestWriterFactory#INSTANCE will be used.

responseParserFactory:HttpMessageParserFactory<ClassicHttpResponse>

response parser factory. If null DefaultHttpResponseParserFactory#INSTANCE will be used.

DefaultBHttpClientConnectionback to summary
public DefaultBHttpClientConnection(final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder, final ContentLengthStrategy incomingContentStrategy, final ContentLengthStrategy outgoingContentStrategy, final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory, final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory)

Creates new instance of DefaultBHttpClientConnection.

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

requestWriterFactory:HttpMessageWriterFactory<ClassicHttpRequest>

request writer factory. If null DefaultHttpRequestWriterFactory#INSTANCE will be used.

responseParserFactory:HttpMessageParserFactory<ClassicHttpResponse>

response parser factory. If null DefaultHttpResponseParserFactory#INSTANCE will be used.

DefaultBHttpClientConnectionback to summary
public DefaultBHttpClientConnection(final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder)
DefaultBHttpClientConnectionback to summary
public DefaultBHttpClientConnection(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.
isConsistentback to summary
public boolean isConsistent()

Implements org.apache.hc.core5.http.io.HttpClientConnection.isConsistent.

Doc from org.apache.hc.core5.http.io.HttpClientConnection.isConsistent.

Checks whether this connection is in a consistent state.

Returns:boolean

true if the connection is known to be in a inconsistent state and cannot be re-used.

Annotations
@Override
onRequestSubmittedback to summary
protected void onRequestSubmitted(final ClassicHttpRequest request)
onResponseReceivedback to summary
protected void onResponseReceived(final ClassicHttpResponse response)
receiveResponseEntityback to summary
public void receiveResponseEntity(final ClassicHttpResponse response) throws HttpException, IOException

Implements org.apache.hc.core5.http.io.HttpClientConnection.receiveResponseEntity.

Doc from org.apache.hc.core5.http.io.HttpClientConnection.receiveResponseEntity.

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

Parameters
response:ClassicHttpResponse

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

Implements org.apache.hc.core5.http.io.HttpClientConnection.receiveResponseHeader.

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

a new HttpResponse object with status line and headers 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
sendRequestEntityback to summary
public void sendRequestEntity(final ClassicHttpRequest request) throws HttpException, IOException

Implements org.apache.hc.core5.http.io.HttpClientConnection.sendRequestEntity.

Doc from org.apache.hc.core5.http.io.HttpClientConnection.sendRequestEntity.

Sends the request entity over the connection.

Parameters
request:ClassicHttpRequest

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

Implements org.apache.hc.core5.http.io.HttpClientConnection.sendRequestHeader.

Doc from org.apache.hc.core5.http.io.HttpClientConnection.sendRequestHeader.

Sends the request line and all headers over the connection.

Parameters
request:ClassicHttpRequest

the request whose headers to send.

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

Implements org.apache.hc.core5.http.io.HttpClientConnection.terminateRequest.

Doc from org.apache.hc.core5.http.io.HttpClientConnection.terminateRequest.

Terminates request prematurely potentially leaving the connection in a inconsistent state.

Parameters
request:ClassicHttpRequest

the request to be terminated prematurely.

Annotations
@Override