Class ClientHttp1StreamDuplexer
java.lang.Object
org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer
- All Implemented Interfaces:
Closeable,AutoCloseable,HttpConnection,SocketModalCloseable,ModalCloseable,Identifiable
I/O event handler for events fired by
ProtocolIOSession that implements
client side HTTP/1.1 messaging protocol with full support for
duplexed message transmission and message pipelining.- Since:
- 5.0
-
Constructor Summary
ConstructorsConstructorDescriptionClientHttp1StreamDuplexer(ProtocolIOSession ioSession, HttpProcessor httpProcessor, Http1Config http1Config, CharCodingConfig charCodingConfig, ConnectionReuseStrategy connectionReuseStrategy, NHttpMessageParser<HttpResponse> incomingMessageParser, NHttpMessageWriter<HttpRequest> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, Http1StreamListener streamListener) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this connection gracefully.voidCloses this process or endpoint and releases any system resources associated with it.protected ContentDecodercreateContentDecoder(long len, ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics) protected ContentEncodercreateContentEncoder(long len, WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics) Returns this connection's endpoint details.getId()Returns this connection's local address ornullif it is not bound yet.Returns this connection's protocol version ornullif unknown.Returns this connection's remote address ornullif it is not connected yet or unconnected.Returns the socket timeout value.Returns this connection's SSL session ornullif TLS has not been activated.protected booleanhandleIncomingMessage(HttpResponse response) protected booleanhandleOutgoingMessage(HttpRequest request) booleanisOpen()Checks if this connection is open.final voidfinal voidfinal voidonException(Exception ex) final voidonInput(ByteBuffer src) final voidonOutput()final voidvoidsetSocketTimeout(Timeout timeout) Sets the socket timeout value.toString()
-
Constructor Details
-
ClientHttp1StreamDuplexer
public ClientHttp1StreamDuplexer(ProtocolIOSession ioSession, HttpProcessor httpProcessor, Http1Config http1Config, CharCodingConfig charCodingConfig, ConnectionReuseStrategy connectionReuseStrategy, NHttpMessageParser<HttpResponse> incomingMessageParser, NHttpMessageWriter<HttpRequest> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, Http1StreamListener streamListener)
-
-
Method Details
-
handleIncomingMessage
- Throws:
HttpException
-
createContentDecoder
protected ContentDecoder createContentDecoder(long len, ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException - Throws:
HttpException
-
handleOutgoingMessage
- Throws:
HttpException
-
createContentEncoder
protected ContentEncoder createContentEncoder(long len, WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException - Throws:
HttpException
-
toString
-
getId
- Specified by:
getIdin interfaceIdentifiable
-
onConnect
- Throws:
HttpExceptionIOException
-
onInput
- Throws:
HttpExceptionIOException
-
onOutput
- Throws:
IOExceptionHttpException
-
onTimeout
- Throws:
IOExceptionHttpException
-
onException
-
onDisconnect
public final void onDisconnect() -
close
Description copied from interface:HttpConnectionCloses 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. Useshutdowninstead.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceHttpConnection- Throws:
IOException
-
close
Description copied from interface:ModalCloseableCloses 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.- Specified by:
closein interfaceModalCloseable- Parameters:
closeMode- How to close the receiver.
-
isOpen
public boolean isOpen()Description copied from interface:HttpConnectionChecks if this connection is open.- Specified by:
isOpenin interfaceHttpConnection- Returns:
- true if it is open, false if it is closed.
-
getSocketTimeout
Description copied from interface:SocketModalCloseableReturns the socket timeout value.- Specified by:
getSocketTimeoutin interfaceSocketModalCloseable- Returns:
- timeout value.
-
setSocketTimeout
Description copied from interface:SocketModalCloseableSets the socket timeout value.- Specified by:
setSocketTimeoutin interfaceSocketModalCloseable- Parameters:
timeout- timeout value
-
getEndpointDetails
Description copied from interface:HttpConnectionReturns this connection's endpoint details.- Specified by:
getEndpointDetailsin interfaceHttpConnection- Returns:
- this connection's endpoint details.
-
getProtocolVersion
Description copied from interface:HttpConnectionReturns this connection's protocol version ornullif unknown.- Specified by:
getProtocolVersionin interfaceHttpConnection- Returns:
- this connection's protocol version or
nullif unknown.
-
getRemoteAddress
Description copied from interface:HttpConnectionReturns this connection's remote address ornullif it is not connected yet or unconnected.- Specified by:
getRemoteAddressin interfaceHttpConnection- Returns:
- this connection's remote address or
nullif it is not connected yet or unconnected.
-
getLocalAddress
Description copied from interface:HttpConnectionReturns this connection's local address ornullif it is not bound yet.- Specified by:
getLocalAddressin interfaceHttpConnection- Returns:
- this connection's local address or
nullif it is not bound yet.
-
getSSLSession
Description copied from interface:HttpConnectionReturns this connection's SSL session ornullif TLS has not been activated.- Specified by:
getSSLSessionin interfaceHttpConnection- Returns:
- this connection's SSL session or
nullif TLS has not been activated.
-