Class ServerHttp1StreamDuplexer
- java.lang.Object
-
- org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
- 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 AbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
I/O event handler for events fired byProtocolIOSession
that implements server side HTTP/1.1 messaging protocol with full support for duplexed message transmission and message pipelining.- Since:
- 5.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ServerHttp1StreamDuplexer.DelayedOutputChannel
-
Nested classes/interfaces inherited from class org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer
AbstractHttp1StreamDuplexer.CapacityWindow, AbstractHttp1StreamDuplexer.MessageDelineation
-
-
Field Summary
Fields Modifier and Type Field Description private ConnectionReuseStrategy
connectionReuseStrategy
private HandlerFactory<AsyncServerExchangeHandler>
exchangeHandlerFactory
private Http1Config
http1Config
private HttpProcessor
httpProcessor
private ServerHttp1StreamHandler
incoming
private ServerHttp1StreamHandler
outgoing
private Http1StreamChannel<HttpResponse>
outputChannel
private java.util.Queue<ServerHttp1StreamHandler>
pipeline
private java.lang.String
scheme
private Http1StreamListener
streamListener
-
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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
appendState(java.lang.StringBuilder buf)
(package private) void
consumeData(java.nio.ByteBuffer src)
(package private) void
consumeHeader(HttpRequest request, EntityDetails entityDetails)
protected ContentDecoder
createContentDecoder(long len, java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics)
protected ContentEncoder
createContentEncoder(long len, java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)
(package private) void
dataEnd(java.util.List<? extends Header> trailers)
(package private) void
disconnected()
(package private) void
execute(RequestExecutionCommand executionCommand)
protected boolean
handleIncomingMessage(HttpRequest request)
protected boolean
handleOutgoingMessage(HttpResponse response)
(package private) boolean
handleTimeout()
(package private) void
inputEnd()
(package private) boolean
inputIdle()
(package private) boolean
isOutputReady()
(package private) void
outputEnd()
(package private) boolean
outputIdle()
(package private) HttpRequest
parseMessageHead(boolean endOfStream)
(package private) void
produceOutput()
(package private) void
terminate(java.lang.Exception exception)
(package private) void
terminateExchange(HttpException ex)
java.lang.String
toString()
(package private) void
updateCapacity(CapacityChannel capacityChannel)
(package private) void
updateInputMetrics(HttpRequest request, BasicHttpConnectionMetrics connMetrics)
(package private) void
updateOutputMetrics(HttpResponse response, BasicHttpConnectionMetrics connMetrics)
-
Methods inherited from class org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer
close, close, commitMessageHead, endOutputStream, getEndpointDetails, getId, getLocalAddress, getProtocolVersion, getRemoteAddress, getSessionTimeout, getSocketTimeout, getSSLSession, isActive, isOpen, isOutputCompleted, isShuttingDown, onConnect, onDisconnect, onException, onInput, onOutput, onTimeout, requestSessionInput, requestSessionOutput, requestShutdown, setSessionTimeout, setSocketTimeout, shutdownSession, shutdownSession, streamOutput, suspendSessionInput, suspendSessionOutput
-
-
-
-
Field Detail
-
scheme
private final java.lang.String scheme
-
httpProcessor
private final HttpProcessor httpProcessor
-
exchangeHandlerFactory
private final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory
-
http1Config
private final Http1Config http1Config
-
connectionReuseStrategy
private final ConnectionReuseStrategy connectionReuseStrategy
-
streamListener
private final Http1StreamListener streamListener
-
pipeline
private final java.util.Queue<ServerHttp1StreamHandler> pipeline
-
outputChannel
private final Http1StreamChannel<HttpResponse> outputChannel
-
outgoing
private volatile ServerHttp1StreamHandler outgoing
-
incoming
private volatile ServerHttp1StreamHandler incoming
-
-
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)
-
-
Method Detail
-
terminate
void terminate(java.lang.Exception exception)
- Specified by:
terminate
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
disconnected
void disconnected()
- Specified by:
disconnected
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
updateInputMetrics
void updateInputMetrics(HttpRequest request, BasicHttpConnectionMetrics connMetrics)
- Specified by:
updateInputMetrics
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
updateOutputMetrics
void updateOutputMetrics(HttpResponse response, BasicHttpConnectionMetrics connMetrics)
- Specified by:
updateOutputMetrics
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
handleIncomingMessage
protected boolean handleIncomingMessage(HttpRequest request) throws HttpException
- Specified by:
handleIncomingMessage
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
-
createContentDecoder
protected ContentDecoder createContentDecoder(long len, java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException
- Specified by:
createContentDecoder
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
-
handleOutgoingMessage
protected boolean handleOutgoingMessage(HttpResponse response) throws HttpException
- Specified by:
handleOutgoingMessage
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
-
createContentEncoder
protected ContentEncoder createContentEncoder(long len, java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException
- Specified by:
createContentEncoder
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
-
inputIdle
boolean inputIdle()
- Specified by:
inputIdle
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
outputIdle
boolean outputIdle()
- Specified by:
outputIdle
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
parseMessageHead
HttpRequest parseMessageHead(boolean endOfStream) throws java.io.IOException, HttpException
- Overrides:
parseMessageHead
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
java.io.IOException
HttpException
-
terminateExchange
void terminateExchange(HttpException ex) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
consumeHeader
void consumeHeader(HttpRequest request, EntityDetails entityDetails) throws HttpException, java.io.IOException
- Specified by:
consumeHeader
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
java.io.IOException
-
consumeData
void consumeData(java.nio.ByteBuffer src) throws HttpException, java.io.IOException
- Specified by:
consumeData
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
java.io.IOException
-
updateCapacity
void updateCapacity(CapacityChannel capacityChannel) throws HttpException, java.io.IOException
- Specified by:
updateCapacity
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
java.io.IOException
-
dataEnd
void dataEnd(java.util.List<? extends Header> trailers) throws HttpException, java.io.IOException
- Specified by:
dataEnd
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
java.io.IOException
-
inputEnd
void inputEnd() throws HttpException, java.io.IOException
- Specified by:
inputEnd
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
java.io.IOException
-
execute
void execute(RequestExecutionCommand executionCommand) throws HttpException
- Specified by:
execute
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
-
isOutputReady
boolean isOutputReady()
- Specified by:
isOutputReady
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
produceOutput
void produceOutput() throws HttpException, java.io.IOException
- Specified by:
produceOutput
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
java.io.IOException
-
outputEnd
void outputEnd() throws HttpException, java.io.IOException
- Specified by:
outputEnd
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
- Throws:
HttpException
java.io.IOException
-
handleTimeout
boolean handleTimeout()
- Specified by:
handleTimeout
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
appendState
void appendState(java.lang.StringBuilder buf)
- Overrides:
appendState
in classAbstractHttp1StreamDuplexer<HttpRequest,HttpResponse>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-