Class DefaultManagedHttpClientConnection
- java.lang.Object
-
- org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection
-
- org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ManagedHttpClientConnection
,org.apache.hc.core5.http.HttpConnection
,org.apache.hc.core5.http.io.BHttpConnection
,org.apache.hc.core5.http.io.HttpClientConnection
,org.apache.hc.core5.http.SocketModalCloseable
,org.apache.hc.core5.io.ModalCloseable
,org.apache.hc.core5.util.Identifiable
final class DefaultManagedHttpClientConnection extends org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection implements ManagedHttpClientConnection, org.apache.hc.core5.util.Identifiable
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBoolean
closed
private static org.slf4j.Logger
HEADER_LOG
private java.lang.String
id
private static org.slf4j.Logger
LOG
private org.apache.hc.core5.util.Timeout
socketTimeout
private static org.slf4j.Logger
WIRE_LOG
-
Constructor Summary
Constructors Constructor Description DefaultManagedHttpClientConnection(java.lang.String id)
DefaultManagedHttpClientConnection(java.lang.String id, java.nio.charset.CharsetDecoder charDecoder, java.nio.charset.CharsetEncoder charEncoder, org.apache.hc.core5.http.config.Http1Config h1Config, org.apache.hc.core5.http.ContentLengthStrategy incomingContentStrategy, org.apache.hc.core5.http.ContentLengthStrategy outgoingContentStrategy, org.apache.hc.core5.http.io.HttpMessageWriterFactory<org.apache.hc.core5.http.ClassicHttpRequest> requestWriterFactory, org.apache.hc.core5.http.io.HttpMessageParserFactory<org.apache.hc.core5.http.ClassicHttpResponse> responseParserFactory)
DefaultManagedHttpClientConnection(java.lang.String id, java.nio.charset.CharsetDecoder charDecoder, java.nio.charset.CharsetEncoder charEncoder, org.apache.hc.core5.http.config.Http1Config h1Config, org.apache.hc.core5.http.ContentLengthStrategy incomingContentStrategy, org.apache.hc.core5.http.ContentLengthStrategy outgoingContentStrategy, org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy responseOutOfOrderStrategy, org.apache.hc.core5.http.io.HttpMessageWriterFactory<org.apache.hc.core5.http.ClassicHttpRequest> requestWriterFactory, org.apache.hc.core5.http.io.HttpMessageParserFactory<org.apache.hc.core5.http.ClassicHttpResponse> responseParserFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate()
Restores the connection from idle mode.protected boolean
awaitInput(org.apache.hc.core5.util.Timeout arg0)
void
bind(java.net.Socket socket)
Binds this connection to the given socket.void
bind(org.apache.hc.core5.http.impl.io.SocketHolder socketHolder)
void
close()
void
close(org.apache.hc.core5.io.CloseMode closeMode)
protected java.io.InputStream
createContentInputStream(long arg0, org.apache.hc.core5.http.io.SessionInputBuffer arg1, java.io.InputStream arg2)
protected java.io.OutputStream
createContentOutputStream(long arg0, org.apache.hc.core5.http.io.SessionOutputBuffer arg1, java.io.OutputStream arg2, org.apache.hc.core5.function.Supplier<java.util.List<? extends org.apache.hc.core5.http.Header>> arg3)
protected org.apache.hc.core5.http.impl.io.SocketHolder
ensureOpen()
void
flush()
org.apache.hc.core5.http.EndpointDetails
getEndpointDetails()
java.lang.String
getId()
java.net.SocketAddress
getLocalAddress()
org.apache.hc.core5.http.ProtocolVersion
getProtocolVersion()
java.net.SocketAddress
getRemoteAddress()
java.net.Socket
getSocket()
Returns the underlying socket.protected org.apache.hc.core5.http.impl.io.SocketHolder
getSocketHolder()
org.apache.hc.core5.util.Timeout
getSocketTimeout()
javax.net.ssl.SSLSession
getSSLSession()
Obtains the SSL session of the underlying connection, if any.protected void
incrementRequestCount()
protected void
incrementResponseCount()
boolean
isDataAvailable(org.apache.hc.core5.util.Timeout arg0)
boolean
isOpen()
boolean
isStale()
protected void
onRequestSubmitted(org.apache.hc.core5.http.ClassicHttpRequest request)
protected void
onResponseReceived(org.apache.hc.core5.http.ClassicHttpResponse response)
void
passivate()
Puts the connection into idle mode.void
setSocketTimeout(org.apache.hc.core5.util.Timeout timeout)
java.lang.String
toString()
-
Methods inherited from class org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection
isConsistent, receiveResponseEntity, receiveResponseHeader, sendRequestEntity, sendRequestHeader, terminateRequest
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.hc.core5.http.io.BHttpConnection
flush, isDataAvailable, isStale
-
Methods inherited from interface org.apache.hc.core5.http.io.HttpClientConnection
isConsistent, receiveResponseEntity, receiveResponseHeader, sendRequestEntity, sendRequestHeader, terminateRequest
-
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
HEADER_LOG
private static final org.slf4j.Logger HEADER_LOG
-
WIRE_LOG
private static final org.slf4j.Logger WIRE_LOG
-
id
private final java.lang.String id
-
closed
private final java.util.concurrent.atomic.AtomicBoolean closed
-
socketTimeout
private org.apache.hc.core5.util.Timeout socketTimeout
-
-
Constructor Detail
-
DefaultManagedHttpClientConnection
public DefaultManagedHttpClientConnection(java.lang.String id, java.nio.charset.CharsetDecoder charDecoder, java.nio.charset.CharsetEncoder charEncoder, org.apache.hc.core5.http.config.Http1Config h1Config, org.apache.hc.core5.http.ContentLengthStrategy incomingContentStrategy, org.apache.hc.core5.http.ContentLengthStrategy outgoingContentStrategy, org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy responseOutOfOrderStrategy, org.apache.hc.core5.http.io.HttpMessageWriterFactory<org.apache.hc.core5.http.ClassicHttpRequest> requestWriterFactory, org.apache.hc.core5.http.io.HttpMessageParserFactory<org.apache.hc.core5.http.ClassicHttpResponse> responseParserFactory)
-
DefaultManagedHttpClientConnection
public DefaultManagedHttpClientConnection(java.lang.String id, java.nio.charset.CharsetDecoder charDecoder, java.nio.charset.CharsetEncoder charEncoder, org.apache.hc.core5.http.config.Http1Config h1Config, org.apache.hc.core5.http.ContentLengthStrategy incomingContentStrategy, org.apache.hc.core5.http.ContentLengthStrategy outgoingContentStrategy, org.apache.hc.core5.http.io.HttpMessageWriterFactory<org.apache.hc.core5.http.ClassicHttpRequest> requestWriterFactory, org.apache.hc.core5.http.io.HttpMessageParserFactory<org.apache.hc.core5.http.ClassicHttpResponse> responseParserFactory)
-
DefaultManagedHttpClientConnection
public DefaultManagedHttpClientConnection(java.lang.String id)
-
-
Method Detail
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceorg.apache.hc.core5.util.Identifiable
-
bind
public void bind(org.apache.hc.core5.http.impl.io.SocketHolder socketHolder) throws java.io.IOException
- Throws:
java.io.IOException
-
getSocket
public java.net.Socket getSocket()
Description copied from interface:ManagedHttpClientConnection
Returns the underlying socket.- Specified by:
getSocket
in interfaceManagedHttpClientConnection
-
getSSLSession
public javax.net.ssl.SSLSession getSSLSession()
Description copied from interface:ManagedHttpClientConnection
Obtains the SSL session of the underlying connection, if any. If this connection is open, and the underlying socket is anSSLSocket
, the SSL session of that socket is obtained. This is a potentially blocking operation.- Specified by:
getSSLSession
in interfaceorg.apache.hc.core5.http.HttpConnection
- Specified by:
getSSLSession
in interfaceManagedHttpClientConnection
- Returns:
- the underlying SSL session if available,
null
otherwise
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceorg.apache.hc.core5.http.HttpConnection
- Throws:
java.io.IOException
-
setSocketTimeout
public void setSocketTimeout(org.apache.hc.core5.util.Timeout timeout)
- Specified by:
setSocketTimeout
in interfaceorg.apache.hc.core5.http.SocketModalCloseable
-
close
public void close(org.apache.hc.core5.io.CloseMode closeMode)
- Specified by:
close
in interfaceorg.apache.hc.core5.io.ModalCloseable
-
bind
public void bind(java.net.Socket socket) throws java.io.IOException
Description copied from interface:ManagedHttpClientConnection
Binds this connection to the given socket. The connection is considered open if it is bound and the underlying socket is connection to a remote host.- Specified by:
bind
in interfaceManagedHttpClientConnection
- Overrides:
bind
in classorg.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection
- Parameters:
socket
- the socket to bind the connection to.- Throws:
java.io.IOException
-
onResponseReceived
protected void onResponseReceived(org.apache.hc.core5.http.ClassicHttpResponse response)
- Overrides:
onResponseReceived
in classorg.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection
-
onRequestSubmitted
protected void onRequestSubmitted(org.apache.hc.core5.http.ClassicHttpRequest request)
- Overrides:
onRequestSubmitted
in classorg.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection
-
passivate
public void passivate()
Description copied from interface:ManagedHttpClientConnection
Puts the connection into idle mode.- Specified by:
passivate
in interfaceManagedHttpClientConnection
-
activate
public void activate()
Description copied from interface:ManagedHttpClientConnection
Restores the connection from idle mode.- Specified by:
activate
in interfaceManagedHttpClientConnection
-
ensureOpen
protected org.apache.hc.core5.http.impl.io.SocketHolder ensureOpen() throws java.io.IOException
- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceorg.apache.hc.core5.http.HttpConnection
-
getProtocolVersion
public org.apache.hc.core5.http.ProtocolVersion getProtocolVersion()
- Specified by:
getProtocolVersion
in interfaceorg.apache.hc.core5.http.HttpConnection
-
getSocketHolder
protected org.apache.hc.core5.http.impl.io.SocketHolder getSocketHolder()
-
createContentOutputStream
protected java.io.OutputStream createContentOutputStream(long arg0, org.apache.hc.core5.http.io.SessionOutputBuffer arg1, java.io.OutputStream arg2, org.apache.hc.core5.function.Supplier<java.util.List<? extends org.apache.hc.core5.http.Header>> arg3)
-
createContentInputStream
protected java.io.InputStream createContentInputStream(long arg0, org.apache.hc.core5.http.io.SessionInputBuffer arg1, java.io.InputStream arg2)
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress()
- Specified by:
getRemoteAddress
in interfaceorg.apache.hc.core5.http.HttpConnection
-
getLocalAddress
public java.net.SocketAddress getLocalAddress()
- Specified by:
getLocalAddress
in interfaceorg.apache.hc.core5.http.HttpConnection
-
getSocketTimeout
public org.apache.hc.core5.util.Timeout getSocketTimeout()
- Specified by:
getSocketTimeout
in interfaceorg.apache.hc.core5.http.SocketModalCloseable
-
awaitInput
protected boolean awaitInput(org.apache.hc.core5.util.Timeout arg0) throws java.io.IOException
- Throws:
java.io.IOException
-
isDataAvailable
public boolean isDataAvailable(org.apache.hc.core5.util.Timeout arg0) throws java.io.IOException
- Specified by:
isDataAvailable
in interfaceorg.apache.hc.core5.http.io.BHttpConnection
- Throws:
java.io.IOException
-
isStale
public boolean isStale() throws java.io.IOException
- Specified by:
isStale
in interfaceorg.apache.hc.core5.http.io.BHttpConnection
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfaceorg.apache.hc.core5.http.io.BHttpConnection
- Throws:
java.io.IOException
-
incrementRequestCount
protected void incrementRequestCount()
-
incrementResponseCount
protected void incrementResponseCount()
-
getEndpointDetails
public org.apache.hc.core5.http.EndpointDetails getEndpointDetails()
- Specified by:
getEndpointDetails
in interfaceorg.apache.hc.core5.http.HttpConnection
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-