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 classAbstractHttp1StreamDuplexer.CapacityWindowprivate static classAbstractHttp1StreamDuplexer.ConnectionState(package private) static classAbstractHttp1StreamDuplexer.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) voidappendState(java.lang.StringBuilder buf)voidclose()Closes this connection gracefully.voidclose(CloseMode closeMode)Closes this process or endpoint and releases any system resources associated with it.(package private) voidcommitMessageHead(OutgoingMessage messageHead, boolean endStream, FlushMode flushMode)(package private) abstract voidconsumeData(java.nio.ByteBuffer src)(package private) abstract voidconsumeHeader(IncomingMessage messageHead, EntityDetails entityDetails)(package private) abstract ContentDecodercreateContentDecoder(long contentLength, java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics)(package private) abstract ContentEncodercreateContentEncoder(long contentLength, java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)(package private) abstract voiddataEnd(java.util.List<? extends Header> trailers)(package private) abstract voiddisconnected()(package private) AbstractHttp1StreamDuplexer.MessageDelineationendOutputStream(java.util.List<? extends Header> trailers)(package private) abstract voidexecute(RequestExecutionCommand executionCommand)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.(package private) TimeoutgetSessionTimeout()TimeoutgetSocketTimeout()Returns the socket timeout value.javax.net.ssl.SSLSessiongetSSLSession()Returns this connection's SSL session ornullif TLS has not been activated.(package private) abstract booleanhandleIncomingMessage(IncomingMessage incomingMessage)(package private) abstract booleanhandleOutgoingMessage(OutgoingMessage outgoingMessage)(package private) abstract booleanhandleTimeout()(package private) abstract voidinputEnd()(package private) abstract booleaninputIdle()(package private) booleanisActive()booleanisOpen()Checks if this connection is open.(package private) booleanisOutputCompleted()(package private) abstract booleanisOutputReady()(package private) booleanisShuttingDown()voidonConnect()voidonDisconnect()voidonException(java.lang.Exception ex)voidonInput(java.nio.ByteBuffer src)voidonOutput()voidonTimeout(Timeout timeout)(package private) abstract voidoutputEnd()(package private) abstract booleanoutputIdle()(package private) IncomingMessageparseMessageHead(boolean endOfStream)private voidprocessCommands()(package private) abstract voidproduceOutput()(package private) voidrequestSessionInput()(package private) voidrequestSessionOutput()(package private) voidrequestShutdown(CloseMode closeMode)(package private) voidsetSessionTimeout(Timeout timeout)voidsetSocketTimeout(Timeout timeout)Sets the socket timeout value.(package private) voidshutdownSession(java.lang.Exception cause)(package private) voidshutdownSession(CloseMode closeMode)(package private) intstreamOutput(java.nio.ByteBuffer src)(package private) voidsuspendSessionInput()(package private) voidsuspendSessionOutput()(package private) abstract voidterminate(java.lang.Exception exception)(package private) abstract voidupdateCapacity(CapacityChannel capacityChannel)(package private) abstract voidupdateInputMetrics(IncomingMessage incomingMessage, BasicHttpConnectionMetrics connMetrics)(package private) abstract voidupdateOutputMetrics(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:
getIdin 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:
HttpExceptionjava.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:
HttpExceptionjava.io.IOException
-
updateCapacity
abstract void updateCapacity(CapacityChannel capacityChannel) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
dataEnd
abstract void dataEnd(java.util.List<? extends Header> trailers) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
isOutputReady
abstract boolean isOutputReady()
-
produceOutput
abstract void produceOutput() throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
execute
abstract void execute(RequestExecutionCommand executionCommand) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
inputEnd
abstract void inputEnd() throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
outputEnd
abstract void outputEnd() throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
inputIdle
abstract boolean inputIdle()
-
outputIdle
abstract boolean outputIdle()
-
handleTimeout
abstract boolean handleTimeout()
-
processCommands
private void processCommands() throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
onConnect
public final void onConnect() throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
parseMessageHead
IncomingMessage parseMessageHead(boolean endOfStream) throws java.io.IOException, HttpException
- Throws:
java.io.IOExceptionHttpException
-
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()
-
requestShutdown
void requestShutdown(CloseMode closeMode)
-
commitMessageHead
void commitMessageHead(OutgoingMessage messageHead, boolean endStream, FlushMode flushMode) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.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.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. Useshutdowninstead.- 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.
-
appendState
void appendState(java.lang.StringBuilder buf)
-
-