Class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,OutgoingMessage extends HttpMessage>
- java.lang.Object
-
- org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer<IncomingMessage,OutgoingMessage>
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,HttpConnection
,SocketModalCloseable
,ModalCloseable
,Identifiable
- Direct Known Subclasses:
ClientHttp1StreamDuplexer
,ServerHttp1StreamDuplexer
abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,OutgoingMessage extends HttpMessage> extends java.lang.Object implements Identifiable, HttpConnection
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AbstractHttp1StreamDuplexer.CapacityWindow
private static class
AbstractHttp1StreamDuplexer.ConnectionState
(package private) static class
AbstractHttp1StreamDuplexer.MessageDelineation
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractHttp1StreamDuplexer(ProtocolIOSession ioSession, Http1Config http1Config, CharCodingConfig charCodingConfig, NHttpMessageParser<IncomingMessage> incomingMessageParser, NHttpMessageWriter<OutgoingMessage> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) void
appendState(java.lang.StringBuilder buf)
void
close()
Closes this connection gracefully.void
close(CloseMode closeMode)
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(java.nio.ByteBuffer src)
(package private) abstract void
consumeHeader(IncomingMessage messageHead, EntityDetails entityDetails)
(package private) abstract ContentDecoder
createContentDecoder(long contentLength, java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics)
(package private) abstract ContentEncoder
createContentEncoder(long contentLength, java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)
(package private) abstract void
dataEnd(java.util.List<? extends Header> trailers)
(package private) abstract void
disconnected()
(package private) AbstractHttp1StreamDuplexer.MessageDelineation
endOutputStream(java.util.List<? extends Header> trailers)
(package private) abstract void
execute(RequestExecutionCommand executionCommand)
EndpointDetails
getEndpointDetails()
Returns this connection's endpoint details.java.lang.String
getId()
java.net.SocketAddress
getLocalAddress()
Returns this connection's local address ornull
if it is not bound yet.ProtocolVersion
getProtocolVersion()
Returns this connection's protocol version ornull
if unknown.java.net.SocketAddress
getRemoteAddress()
Returns this connection's remote address ornull
if it is not connected yet or unconnected.(package private) Timeout
getSessionTimeout()
Timeout
getSocketTimeout()
Returns the socket timeout value.javax.net.ssl.SSLSession
getSSLSession()
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
handleTimeout()
(package private) abstract void
inputEnd()
(package private) abstract boolean
inputIdle()
(package private) boolean
isActive()
boolean
isOpen()
Checks if this connection is open.(package private) boolean
isOutputCompleted()
(package private) abstract boolean
isOutputReady()
(package private) boolean
isShuttingDown()
void
onConnect()
void
onDisconnect()
void
onException(java.lang.Exception ex)
void
onInput(java.nio.ByteBuffer src)
void
onOutput()
void
onTimeout(Timeout timeout)
(package private) abstract void
outputEnd()
(package private) abstract boolean
outputIdle()
(package private) IncomingMessage
parseMessageHead(boolean endOfStream)
private void
processCommands()
(package private) abstract void
produceOutput()
(package private) void
requestSessionInput()
(package private) void
requestSessionOutput()
(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(java.lang.Exception cause)
(package private) void
shutdownSession(CloseMode closeMode)
(package private) int
streamOutput(java.nio.ByteBuffer src)
(package private) void
suspendSessionInput()
(package private) void
suspendSessionOutput()
(package private) abstract void
terminate(java.lang.Exception exception)
(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 Detail
-
ioSession
private final ProtocolIOSession ioSession
-
http1Config
private final Http1Config http1Config
-
inbuf
private final SessionInputBufferImpl inbuf
-
outbuf
private final SessionOutputBufferImpl outbuf
-
inTransportMetrics
private final BasicHttpTransportMetrics inTransportMetrics
-
outTransportMetrics
private final BasicHttpTransportMetrics outTransportMetrics
-
connMetrics
private final BasicHttpConnectionMetrics connMetrics
-
incomingMessageParser
private final NHttpMessageParser<IncomingMessage extends HttpMessage> incomingMessageParser
-
outgoingMessageWriter
private final NHttpMessageWriter<OutgoingMessage extends HttpMessage> outgoingMessageWriter
-
incomingContentStrategy
private final ContentLengthStrategy incomingContentStrategy
-
outgoingContentStrategy
private final ContentLengthStrategy outgoingContentStrategy
-
contentBuffer
private final java.nio.ByteBuffer contentBuffer
-
outputRequests
private final java.util.concurrent.atomic.AtomicInteger outputRequests
-
incomingMessage
private volatile Message<IncomingMessage extends HttpMessage,ContentDecoder> incomingMessage
-
outgoingMessage
private volatile Message<OutgoingMessage extends HttpMessage,ContentEncoder> outgoingMessage
-
connState
private volatile AbstractHttp1StreamDuplexer.ConnectionState connState
-
capacityWindow
private volatile AbstractHttp1StreamDuplexer.CapacityWindow capacityWindow
-
version
private volatile ProtocolVersion version
-
endpointDetails
private volatile EndpointDetails endpointDetails
-
-
Constructor Detail
-
AbstractHttp1StreamDuplexer
AbstractHttp1StreamDuplexer(ProtocolIOSession ioSession, Http1Config http1Config, CharCodingConfig charCodingConfig, NHttpMessageParser<IncomingMessage> incomingMessageParser, NHttpMessageWriter<OutgoingMessage> outgoingMessageWriter, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy)
-
-
Method Detail
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceIdentifiable
-
isActive
boolean isActive()
-
isShuttingDown
boolean isShuttingDown()
-
shutdownSession
void shutdownSession(CloseMode closeMode)
-
shutdownSession
void shutdownSession(java.lang.Exception cause)
-
disconnected
abstract void disconnected()
-
terminate
abstract void terminate(java.lang.Exception exception)
-
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, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
handleIncomingMessage
abstract boolean handleIncomingMessage(IncomingMessage incomingMessage) throws HttpException
- Throws:
HttpException
-
handleOutgoingMessage
abstract boolean handleOutgoingMessage(OutgoingMessage outgoingMessage) throws HttpException
- Throws:
HttpException
-
createContentDecoder
abstract ContentDecoder createContentDecoder(long contentLength, java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException
- Throws:
HttpException
-
createContentEncoder
abstract ContentEncoder createContentEncoder(long contentLength, java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics) throws HttpException
- Throws:
HttpException
-
consumeData
abstract void consumeData(java.nio.ByteBuffer src) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
updateCapacity
abstract void updateCapacity(CapacityChannel capacityChannel) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
dataEnd
abstract void dataEnd(java.util.List<? extends Header> trailers) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
isOutputReady
abstract boolean isOutputReady()
-
produceOutput
abstract void produceOutput() throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
execute
abstract void execute(RequestExecutionCommand executionCommand) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
inputEnd
abstract void inputEnd() throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
outputEnd
abstract void outputEnd() throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
inputIdle
abstract boolean inputIdle()
-
outputIdle
abstract boolean outputIdle()
-
handleTimeout
abstract boolean handleTimeout()
-
processCommands
private void processCommands() throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
onConnect
public final void onConnect() throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
parseMessageHead
IncomingMessage parseMessageHead(boolean endOfStream) throws java.io.IOException, HttpException
- Throws:
java.io.IOException
HttpException
-
onInput
public final void onInput(java.nio.ByteBuffer src) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
onOutput
public final void onOutput() throws java.io.IOException, HttpException
- Throws:
java.io.IOException
HttpException
-
onTimeout
public final void onTimeout(Timeout timeout) throws java.io.IOException, HttpException
- Throws:
java.io.IOException
HttpException
-
onException
public final void onException(java.lang.Exception ex)
-
onDisconnect
public final void onDisconnect()
-
requestShutdown
void requestShutdown(CloseMode closeMode)
-
commitMessageHead
void commitMessageHead(OutgoingMessage messageHead, boolean endStream, FlushMode flushMode) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
requestSessionInput
void requestSessionInput()
-
requestSessionOutput
void requestSessionOutput()
-
getSessionTimeout
Timeout getSessionTimeout()
-
setSessionTimeout
void setSessionTimeout(Timeout timeout)
-
suspendSessionInput
void suspendSessionInput()
-
suspendSessionOutput
void suspendSessionOutput() throws java.io.IOException
- Throws:
java.io.IOException
-
streamOutput
int streamOutput(java.nio.ByteBuffer src) throws java.io.IOException
- Throws:
java.io.IOException
-
endOutputStream
AbstractHttp1StreamDuplexer.MessageDelineation endOutputStream(java.util.List<? extends Header> trailers) throws java.io.IOException
- Throws:
java.io.IOException
-
isOutputCompleted
boolean isOutputCompleted()
-
close
public void close() throws java.io.IOException
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceHttpConnection
- Throws:
java.io.IOException
-
close
public void close(CloseMode closeMode)
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
public Timeout getSocketTimeout()
Description copied from interface:SocketModalCloseable
Returns the socket timeout value.- Specified by:
getSocketTimeout
in interfaceSocketModalCloseable
- Returns:
- timeout value.
-
setSocketTimeout
public void setSocketTimeout(Timeout timeout)
Description copied from interface:SocketModalCloseable
Sets the socket timeout value.- Specified by:
setSocketTimeout
in interfaceSocketModalCloseable
- Parameters:
timeout
- timeout value
-
getEndpointDetails
public EndpointDetails getEndpointDetails()
Description copied from interface:HttpConnection
Returns this connection's endpoint details.- Specified by:
getEndpointDetails
in interfaceHttpConnection
- Returns:
- this connection's endpoint details.
-
getProtocolVersion
public ProtocolVersion 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
public java.net.SocketAddress 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
public java.net.SocketAddress 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
public javax.net.ssl.SSLSession 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
void appendState(java.lang.StringBuilder buf)
-
-