Class ServerHttp1StreamDuplexer
- java.lang.Object
-
- org.apache.hc.core5.http.impl.nio.ServerHttp1StreamDuplexer
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,HttpConnection,SocketModalCloseable,ModalCloseable,Identifiable
@Internal public class ServerHttp1StreamDuplexer extends java.lang.Object
I/O event handler for events fired byProtocolIOSessionthat implements server side HTTP/1.1 messaging protocol with full support for duplexed message transmission and message pipelining.- Since:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description ServerHttp1StreamDuplexer(ProtocolIOSession ioSession, HttpProcessor httpProcessor, HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory, java.lang.String scheme, Http1Config http1Config, CharCodingConfig charCodingConfig, ConnectionReuseStrategy connectionReuseStrategy, NHttpMessageParser<HttpRequest> incomingMessageParser, NHttpMessageWriter<HttpResponse> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, Http1StreamListener streamListener, Callback<java.lang.Exception> exceptionCallback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this connection gracefully.voidclose(CloseMode closeMode)Closes this process or endpoint and releases any system resources associated with it.protected ContentDecodercreateContentDecoder(long len, java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics)protected ContentEncodercreateContentEncoder(long len, java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)EndpointDetailsgetEndpointDetails()Returns this connection's endpoint details.java.lang.StringgetId()java.net.SocketAddressgetLocalAddress()Returns this connection's local address ornullif it is not bound yet.ProtocolVersiongetProtocolVersion()Returns this connection's protocol version ornullif unknown.java.net.SocketAddressgetRemoteAddress()Returns this connection's remote address ornullif it is not connected yet or unconnected.TimeoutgetSocketTimeout()Returns the socket timeout value.javax.net.ssl.SSLSessiongetSSLSession()Returns this connection's SSL session ornullif TLS has not been activated.protected booleanhandleIncomingMessage(HttpRequest request)protected booleanhandleOutgoingMessage(HttpResponse response)booleanisOpen()Checks if this connection is open.voidonConnect()voidonDisconnect()voidonException(java.lang.Exception ex)voidonInput(java.nio.ByteBuffer src)voidonOutput()voidonTimeout(Timeout timeout)voidsetSocketTimeout(Timeout timeout)Sets the socket timeout value.java.lang.StringtoString()-
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.HttpConnection
isIdle
-
-
-
-
Constructor Detail
-
ServerHttp1StreamDuplexer
public ServerHttp1StreamDuplexer(ProtocolIOSession ioSession, HttpProcessor httpProcessor, HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory, java.lang.String scheme, Http1Config http1Config, CharCodingConfig charCodingConfig, ConnectionReuseStrategy connectionReuseStrategy, NHttpMessageParser<HttpRequest> incomingMessageParser, NHttpMessageWriter<HttpResponse> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, Http1StreamListener streamListener, Callback<java.lang.Exception> exceptionCallback)
-
-
Method Detail
-
handleIncomingMessage
protected boolean handleIncomingMessage(HttpRequest request) throws HttpException
- Throws:
HttpException
-
createContentDecoder
protected ContentDecoder createContentDecoder(long len, java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException
- Throws:
HttpException
-
handleOutgoingMessage
protected boolean handleOutgoingMessage(HttpResponse response) throws HttpException
- Throws:
HttpException
-
createContentEncoder
protected ContentEncoder createContentEncoder(long len, java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException
- Throws:
HttpException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getId
public java.lang.String getId()
- Specified by:
getIdin interfaceIdentifiable
-
onConnect
public final void onConnect() throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
onInput
public final void onInput(java.nio.ByteBuffer src) throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
onOutput
public final void onOutput() throws java.io.IOException, HttpException- Throws:
java.io.IOExceptionHttpException
-
onTimeout
public final void onTimeout(Timeout timeout) throws java.io.IOException, HttpException
- Throws:
java.io.IOExceptionHttpException
-
onException
public final void onException(java.lang.Exception ex)
-
onDisconnect
public final void onDisconnect()
-
close
public void close() throws java.io.IOExceptionDescription 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. Useclose(CloseMode.IMMEDIATE)instead.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceHttpConnection- Throws:
java.io.IOException
-
close
public void close(CloseMode closeMode)
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
public Timeout getSocketTimeout()
Description copied from interface:SocketModalCloseableReturns the socket timeout value.- Specified by:
getSocketTimeoutin interfaceSocketModalCloseable- Returns:
- timeout value.
-
setSocketTimeout
public void setSocketTimeout(Timeout timeout)
Description copied from interface:SocketModalCloseableSets the socket timeout value.- Specified by:
setSocketTimeoutin interfaceSocketModalCloseable- Parameters:
timeout- timeout value
-
getEndpointDetails
public EndpointDetails getEndpointDetails()
Description copied from interface:HttpConnectionReturns this connection's endpoint details.- Specified by:
getEndpointDetailsin interfaceHttpConnection- Returns:
- this connection's endpoint details.
-
getProtocolVersion
public ProtocolVersion 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
public java.net.SocketAddress 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
public java.net.SocketAddress 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
public javax.net.ssl.SSLSession 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.
-
-