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

pack-priv Class BHttpConnectionBase

extends Object
implements BHttpConnection
Class Inheritance
All Implemented Interfaces
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
Known Direct Subclasses
org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection, org.apache.hc.core5.http.impl.io.DefaultBHttpServerConnection
Imports
java.io.IOException, .InputStream, .OutputStream, java.net.Socket, .SocketAddress, .SocketException, .SocketTimeoutException, java.nio.charset.CharsetDecoder, .CharsetEncoder, java.util.List, java.util.concurrent.atomic.AtomicReference, javax.net.ssl.SSLSession, .SSLSocket, org.apache.hc.core5.function.Supplier, org.apache.hc.core5.http.ConnectionClosedException, .ContentLengthStrategy, .EndpointDetails, .Header, .HttpEntity, .HttpHeaders, .HttpMessage, .ProtocolVersion, org.apache.hc.core5.http.config.Http1Config, org.apache.hc.core5.http.impl.BasicEndpointDetails, .BasicHttpConnectionMetrics, .BasicHttpTransportMetrics, org.apache.hc.core5.http.io.BHttpConnection, .SessionInputBuffer, .SessionOutputBuffer, org.apache.hc.core5.http.io.entity.EmptyInputStream, org.apache.hc.core5.io.CloseMode, .Closer, org.apache.hc.core5.net.InetAddressUtils, org.apache.hc.core5.util.Args, .Timeout

Field Summary

Modifier and TypeField and Description
private byte[]
pack-priv final BasicHttpConnectionMetrics
pack-priv volatile EndpointDetails
pack-priv final Http1Config
pack-priv final SessionInputBufferImpl
pack-priv final SessionOutputBufferImpl
pack-priv final AtomicReference<SocketHolder>
private static final Timeout
pack-priv volatile ProtocolVersion

Constructor Summary

AccessConstructor and Description
pack-priv
BHttpConnectionBase(final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder)

Method Summary

Modifier and TypeMethod and Description
protected boolean
awaitInput(final Timeout timeout)

protected void
bind(final Socket
the socket.
socket
)

Binds this connection to the given Socket.

protected void
bind(final SocketHolder socketHolder)

public void
close(final CloseMode
How to close the receiver.
closeMode
)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Closes this process or endpoint and releases any system resources associated with it.
public void
close()

Implements org.apache.hc.core5.http.HttpConnection.close.

Closes this connection gracefully.
protected InputStream
createContentInputStream(final long len, final SessionInputBuffer buffer, final InputStream inputStream)

protected OutputStream
createContentOutputStream(final long len, final SessionOutputBuffer buffer, final OutputStream outputStream, final Supplier<List<? extends Header>> trailers)

pack-priv HttpEntity
createIncomingEntity(final HttpMessage message, final SessionInputBuffer inBuffer, final InputStream inputStream, final long len)

protected SocketHolder
private int
fillInputBuffer(final Timeout timeout)

public void
flush()

Implements org.apache.hc.core5.http.io.BHttpConnection.flush.

Writes out all pending buffered data over the open connection.
private byte[]
public EndpointDetails
getEndpointDetails()

Implements org.apache.hc.core5.http.HttpConnection.getEndpointDetails.

Returns this connection's endpoint details.
public SocketAddress
getLocalAddress()

Implements org.apache.hc.core5.http.HttpConnection.getLocalAddress.

Returns this connection's local address or null if it is not bound yet.
public ProtocolVersion
getProtocolVersion()

Implements org.apache.hc.core5.http.HttpConnection.getProtocolVersion.

Returns this connection's protocol version or null if unknown.
public SocketAddress
getRemoteAddress()

Implements org.apache.hc.core5.http.HttpConnection.getRemoteAddress.

Returns this connection's remote address or null if it is not connected yet or unconnected.
protected SocketHolder
public Timeout
public SSLSession
getSSLSession()

Implements org.apache.hc.core5.http.HttpConnection.getSSLSession.

Returns this connection's SSL session or null if TLS has not been activated.
protected void
protected void
public boolean
isDataAvailable(final Timeout
the maximum time to wait for data
timeout
)

Implements org.apache.hc.core5.http.io.BHttpConnection.isDataAvailable.

Checks if input data is available from the connection.
public boolean
isOpen()

Implements org.apache.hc.core5.http.HttpConnection.isOpen.

Checks if this connection is open.
public boolean
isStale()

Implements org.apache.hc.core5.http.io.BHttpConnection.isStale.

Checks whether this connection has gone down.
public void
setSocketTimeout(final Timeout
timeout value
timeout
)

Implements org.apache.hc.core5.http.SocketModalCloseable.setSocketTimeout.

Sets the socket timeout value.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

chunkedRequestBufferback to summary
private byte[] chunkedRequestBuffer
connMetricsback to summary
pack-priv final BasicHttpConnectionMetrics connMetrics
endpointDetailsback to summary
pack-priv volatile EndpointDetails endpointDetails
http1Configback to summary
pack-priv final Http1Config http1Config
inBufferback to summary
pack-priv final SessionInputBufferImpl inBuffer
outbufferback to summary
pack-priv final SessionOutputBufferImpl outbuffer
socketHolderRefback to summary
pack-priv final AtomicReference<SocketHolder> socketHolderRef
STALE_CHECK_TIMEOUTback to summary
private static final Timeout STALE_CHECK_TIMEOUT
versionback to summary
pack-priv volatile ProtocolVersion version

Constructor Detail

BHttpConnectionBaseback to summary
pack-priv BHttpConnectionBase(final Http1Config http1Config, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder)

Method Detail

awaitInputback to summary
protected boolean awaitInput(final Timeout timeout) throws IOException
bindback to summary
protected void bind(final Socket socket) throws IOException

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.

Exceptions
IOException:
in case of an I/O error.
bindback to summary
protected void bind(final SocketHolder socketHolder) throws IOException
closeback to summary
public void close(final CloseMode closeMode)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Doc from org.apache.hc.core5.io.ModalCloseable.close.

Closes this process or endpoint and releases any system resources associated with it. If the endpoint or the process is already closed then invoking this method has no effect.

Parameters
closeMode:CloseMode

How to close the receiver.

Annotations
@Override
closeback to summary
public void close() throws IOException

Implements org.apache.hc.core5.http.HttpConnection.close.

Doc from org.apache.hc.core5.http.HttpConnection.close.

Closes this connection gracefully. This method will attempt to flush the internal output buffer prior to closing the underlying socket. This method MUST NOT be called from a different thread to force shutdown of the connection. Use shutdown instead.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Closeable.close.

if an I/O error occurs

createContentInputStreamback to summary
protected InputStream createContentInputStream(final long len, final SessionInputBuffer buffer, final InputStream inputStream)
createContentOutputStreamback to summary
protected OutputStream createContentOutputStream(final long len, final SessionOutputBuffer buffer, final OutputStream outputStream, final Supplier<List<? extends Header>> trailers)
createIncomingEntityback to summary
pack-priv HttpEntity createIncomingEntity(final HttpMessage message, final SessionInputBuffer inBuffer, final InputStream inputStream, final long len)
ensureOpenback to summary
protected SocketHolder ensureOpen() throws IOException
fillInputBufferback to summary
private int fillInputBuffer(final Timeout timeout) throws IOException
flushback to summary
public void flush() throws IOException

Implements org.apache.hc.core5.http.io.BHttpConnection.flush.

Doc from org.apache.hc.core5.http.io.BHttpConnection.flush.

Writes out all pending buffered data over the open connection.

Annotations
@Override
Exceptions
IOException:
in case of an I/O error
getChunkedRequestBufferback to summary
private byte[] getChunkedRequestBuffer()
getEndpointDetailsback to summary
public EndpointDetails getEndpointDetails()

Implements org.apache.hc.core5.http.HttpConnection.getEndpointDetails.

Doc from org.apache.hc.core5.http.HttpConnection.getEndpointDetails.

Returns this connection's endpoint details.

Returns:EndpointDetails

this connection's endpoint details.

Annotations
@Override
getLocalAddressback to summary
public SocketAddress getLocalAddress()

Implements org.apache.hc.core5.http.HttpConnection.getLocalAddress.

Doc from org.apache.hc.core5.http.HttpConnection.getLocalAddress.

Returns this connection's local address or null if it is not bound yet.

Returns:SocketAddress

this connection's local address or null if it is not bound yet.

Annotations
@Override
getProtocolVersionback to summary
public ProtocolVersion getProtocolVersion()

Implements org.apache.hc.core5.http.HttpConnection.getProtocolVersion.

Doc from org.apache.hc.core5.http.HttpConnection.getProtocolVersion.

Returns this connection's protocol version or null if unknown.

Returns:ProtocolVersion

this connection's protocol version or null if unknown.

Annotations
@Override
Since
5.0
getRemoteAddressback to summary
public SocketAddress getRemoteAddress()

Implements org.apache.hc.core5.http.HttpConnection.getRemoteAddress.

Doc from org.apache.hc.core5.http.HttpConnection.getRemoteAddress.

Returns this connection's remote address or null if it is not connected yet or unconnected.

Returns:SocketAddress

this connection's remote address or null if it is not connected yet or unconnected.

Annotations
@Override
getSocketHolderback to summary
protected SocketHolder getSocketHolder()
getSocketTimeoutback to summary
public Timeout getSocketTimeout()

Implements org.apache.hc.core5.http.SocketModalCloseable.getSocketTimeout.

Doc from org.apache.hc.core5.http.SocketModalCloseable.getSocketTimeout.

Returns the socket timeout value.

Returns:Timeout

timeout value.

Annotations
@Override
getSSLSessionback to summary
public SSLSession getSSLSession()

Implements org.apache.hc.core5.http.HttpConnection.getSSLSession.

Doc from org.apache.hc.core5.http.HttpConnection.getSSLSession.

Returns this connection's SSL session or null if TLS has not been activated.

Returns:SSLSession

this connection's SSL session or null if TLS has not been activated.

Annotations
@Override
incrementRequestCountback to summary
protected void incrementRequestCount()
incrementResponseCountback to summary
protected void incrementResponseCount()
isDataAvailableback to summary
public boolean isDataAvailable(final Timeout timeout) throws IOException

Implements org.apache.hc.core5.http.io.BHttpConnection.isDataAvailable.

Doc from org.apache.hc.core5.http.io.BHttpConnection.isDataAvailable.

Checks if input 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:Timeout

the maximum time to wait for data

Returns:boolean

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

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

Implements org.apache.hc.core5.http.HttpConnection.isOpen.

Doc from org.apache.hc.core5.http.HttpConnection.isOpen.

Checks if this connection is open.

Returns:boolean

true if it is open, false if it is closed.

Annotations
@Override
isStaleback to summary
public boolean isStale() throws IOException

Implements org.apache.hc.core5.http.io.BHttpConnection.isStale.

Doc from org.apache.hc.core5.http.io.BHttpConnection.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 fail and this connection should be closed, or false if they are likely to succeed

Annotations
@Override
setSocketTimeoutback to summary
public void setSocketTimeout(final Timeout timeout)

Implements org.apache.hc.core5.http.SocketModalCloseable.setSocketTimeout.

Doc from org.apache.hc.core5.http.SocketModalCloseable.setSocketTimeout.

Sets the socket timeout value.

Parameters
timeout:Timeout

timeout value

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override