Class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,OutgoingMessage extends HttpMessage>
java.lang.Object
org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer<IncomingMessage,OutgoingMessage>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,HttpConnection
,SocketModalCloseable
,ModalCloseable
,Identifiable
- Direct Known Subclasses:
ClientHttp1StreamDuplexer
,ServerHttp1StreamDuplexer
abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,OutgoingMessage extends HttpMessage>
extends Object
implements Identifiable, HttpConnection
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
private static enum
(package private) static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BasicHttpConnectionMetrics
private final ByteBuffer
private EndpointDetails
private final Http1Config
private final SessionInputBufferImpl
private final ContentLengthStrategy
private Message
<IncomingMessage, ContentDecoder> private final NHttpMessageParser
<IncomingMessage> private final BasicHttpTransportMetrics
private final ProtocolIOSession
private final SessionOutputBufferImpl
private final ContentLengthStrategy
private Message
<OutgoingMessage, ContentEncoder> private final NHttpMessageWriter
<OutgoingMessage> private final AtomicInteger
private final BasicHttpTransportMetrics
private ProtocolVersion
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractHttp1StreamDuplexer
(ProtocolIOSession ioSession, Http1Config http1Config, CharCodingConfig charCodingConfig, NHttpMessageParser<IncomingMessage> incomingMessageParser, NHttpMessageWriter<OutgoingMessage> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy) -
Method Summary
Modifier and TypeMethodDescription(package private) void
appendState
(StringBuilder buf) void
close()
Closes this connection gracefully.void
Closes this process or endpoint and releases any system resources associated with it.(package private) void
commitMessageHead
(OutgoingMessage messageHead, boolean endStream, FlushMode flushMode) (package private) abstract void
consumeData
(ByteBuffer src) (package private) abstract void
consumeHeader
(IncomingMessage messageHead, EntityDetails entityDetails) (package private) abstract ContentDecoder
createContentDecoder
(long contentLength, ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics) (package private) abstract ContentEncoder
createContentEncoder
(long contentLength, WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics) (package private) abstract void
(package private) abstract void
(package private) AbstractHttp1StreamDuplexer.MessageDelineation
endOutputStream
(List<? extends Header> trailers) (package private) abstract void
execute
(RequestExecutionCommand executionCommand) Returns this connection's endpoint details.getId()
Returns this connection's local address ornull
if it is not bound yet.Returns this connection's protocol version ornull
if unknown.Returns this connection's remote address ornull
if it is not connected yet or unconnected.(package private) Timeout
Returns the socket timeout value.Returns this connection's SSL session ornull
if TLS has not been activated.(package private) abstract boolean
handleIncomingMessage
(IncomingMessage incomingMessage) (package private) abstract boolean
handleOutgoingMessage
(OutgoingMessage outgoingMessage) (package private) abstract boolean
(package private) abstract void
inputEnd()
(package private) abstract boolean
(package private) boolean
isActive()
boolean
isOpen()
Checks if this connection is open.(package private) boolean
(package private) abstract boolean
(package private) boolean
final void
final void
final void
onException
(Exception ex) final void
onInput
(ByteBuffer src) final void
onOutput()
final void
(package private) abstract void
(package private) abstract boolean
(package private) IncomingMessage
parseMessageHead
(boolean endOfStream) private void
(package private) abstract void
(package private) void
(package private) void
(package private) void
requestShutdown
(CloseMode closeMode) (package private) void
setSessionTimeout
(Timeout timeout) void
setSocketTimeout
(Timeout timeout) Sets the socket timeout value.(package private) void
shutdownSession
(Exception cause) (package private) void
shutdownSession
(CloseMode closeMode) (package private) int
streamOutput
(ByteBuffer src) (package private) void
(package private) void
(package private) abstract void
(package private) abstract void
updateCapacity
(CapacityChannel capacityChannel) (package private) abstract void
updateInputMetrics
(IncomingMessage incomingMessage, BasicHttpConnectionMetrics connMetrics) (package private) abstract void
updateOutputMetrics
(OutgoingMessage outgoingMessage, BasicHttpConnectionMetrics connMetrics)
-
Field Details
-
ioSession
-
http1Config
-
inbuf
-
outbuf
-
inTransportMetrics
-
outTransportMetrics
-
connMetrics
-
incomingMessageParser
-
outgoingMessageWriter
-
incomingContentStrategy
-
outgoingContentStrategy
-
contentBuffer
-
outputRequests
-
incomingMessage
-
outgoingMessage
-
connState
-
capacityWindow
-
version
-
endpointDetails
-
-
Constructor Details
-
AbstractHttp1StreamDuplexer
AbstractHttp1StreamDuplexer(ProtocolIOSession ioSession, Http1Config http1Config, CharCodingConfig charCodingConfig, NHttpMessageParser<IncomingMessage> incomingMessageParser, NHttpMessageWriter<OutgoingMessage> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy)
-
-
Method Details
-
getId
- Specified by:
getId
in interfaceIdentifiable
-
isActive
boolean isActive() -
isShuttingDown
boolean isShuttingDown() -
shutdownSession
-
shutdownSession
-
disconnected
abstract void disconnected() -
terminate
-
updateInputMetrics
abstract void updateInputMetrics(IncomingMessage incomingMessage, BasicHttpConnectionMetrics connMetrics) -
updateOutputMetrics
abstract void updateOutputMetrics(OutgoingMessage outgoingMessage, BasicHttpConnectionMetrics connMetrics) -
consumeHeader
abstract void consumeHeader(IncomingMessage messageHead, EntityDetails entityDetails) throws HttpException, IOException - Throws:
HttpException
IOException
-
handleIncomingMessage
- Throws:
HttpException
-
handleOutgoingMessage
- Throws:
HttpException
-
createContentDecoder
abstract ContentDecoder createContentDecoder(long contentLength, ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException - Throws:
HttpException
-
createContentEncoder
abstract ContentEncoder createContentEncoder(long contentLength, WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException - Throws:
HttpException
-
consumeData
- Throws:
HttpException
IOException
-
updateCapacity
- Throws:
HttpException
IOException
-
dataEnd
- Throws:
HttpException
IOException
-
isOutputReady
abstract boolean isOutputReady() -
produceOutput
- Throws:
HttpException
IOException
-
execute
- Throws:
HttpException
IOException
-
inputEnd
- Throws:
HttpException
IOException
-
outputEnd
- Throws:
HttpException
IOException
-
inputIdle
abstract boolean inputIdle() -
outputIdle
abstract boolean outputIdle() -
handleTimeout
abstract boolean handleTimeout() -
processCommands
- Throws:
HttpException
IOException
-
onConnect
- Throws:
HttpException
IOException
-
parseMessageHead
- Throws:
IOException
HttpException
-
onInput
- Throws:
HttpException
IOException
-
onOutput
- Throws:
IOException
HttpException
-
onTimeout
- Throws:
IOException
HttpException
-
onException
-
onDisconnect
public final void onDisconnect() -
requestShutdown
-
commitMessageHead
void commitMessageHead(OutgoingMessage messageHead, boolean endStream, FlushMode flushMode) throws HttpException, IOException - Throws:
HttpException
IOException
-
requestSessionInput
void requestSessionInput() -
requestSessionOutput
void requestSessionOutput() -
getSessionTimeout
Timeout getSessionTimeout() -
setSessionTimeout
-
suspendSessionInput
void suspendSessionInput() -
suspendSessionOutput
- Throws:
IOException
-
streamOutput
- Throws:
IOException
-
endOutputStream
AbstractHttp1StreamDuplexer.MessageDelineation endOutputStream(List<? extends Header> trailers) throws IOException - Throws:
IOException
-
isOutputCompleted
boolean isOutputCompleted() -
close
Description copied from interface:HttpConnection
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. Useshutdown
instead.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceHttpConnection
- Throws:
IOException
-
close
Description copied from interface:ModalCloseable
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.- Specified by:
close
in interfaceModalCloseable
- Parameters:
closeMode
- How to close the receiver.
-
isOpen
public boolean isOpen()Description copied from interface:HttpConnection
Checks if this connection is open.- Specified by:
isOpen
in interfaceHttpConnection
- Returns:
- true if it is open, false if it is closed.
-
getSocketTimeout
Description copied from interface:SocketModalCloseable
Returns the socket timeout value.- Specified by:
getSocketTimeout
in interfaceSocketModalCloseable
- Returns:
- timeout value.
-
setSocketTimeout
Description copied from interface:SocketModalCloseable
Sets the socket timeout value.- Specified by:
setSocketTimeout
in interfaceSocketModalCloseable
- Parameters:
timeout
- timeout value
-
getEndpointDetails
Description copied from interface:HttpConnection
Returns this connection's endpoint details.- Specified by:
getEndpointDetails
in interfaceHttpConnection
- Returns:
- this connection's endpoint details.
-
getProtocolVersion
Description copied from interface:HttpConnection
Returns this connection's protocol version ornull
if unknown.- Specified by:
getProtocolVersion
in interfaceHttpConnection
- Returns:
- this connection's protocol version or
null
if unknown.
-
getRemoteAddress
Description copied from interface:HttpConnection
Returns this connection's remote address ornull
if it is not connected yet or unconnected.- Specified by:
getRemoteAddress
in interfaceHttpConnection
- Returns:
- this connection's remote address or
null
if it is not connected yet or unconnected.
-
getLocalAddress
Description copied from interface:HttpConnection
Returns this connection's local address ornull
if it is not bound yet.- Specified by:
getLocalAddress
in interfaceHttpConnection
- Returns:
- this connection's local address or
null
if it is not bound yet.
-
getSSLSession
Description copied from interface:HttpConnection
Returns this connection's SSL session ornull
if TLS has not been activated.- Specified by:
getSSLSession
in interfaceHttpConnection
- Returns:
- this connection's SSL session or
null
if TLS has not been activated.
-
appendState
-