Package org.apache.http.impl.nio
Class DefaultNHttpServerConnection
java.lang.Object
org.apache.http.impl.nio.NHttpConnectionBase
org.apache.http.impl.nio.DefaultNHttpServerConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
,HttpConnection
,HttpInetConnection
,IOControl
,NHttpConnection
,NHttpServerConnection
,NHttpServerIOTarget
,SessionBufferStatus
,SocketAccessor
public class DefaultNHttpServerConnection
extends NHttpConnectionBase
implements NHttpServerIOTarget
Default implementation of the
NHttpServerConnection
interface.- Since:
- 4.0
-
Field Summary
Fields inherited from interface org.apache.http.nio.NHttpConnection
ACTIVE, CLOSED, CLOSING
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultNHttpServerConnection
(IOSession session, int buffersize) DefaultNHttpServerConnection
(IOSession session, int buffersize, int fragmentSizeHint, ByteBufferAllocator allocator, CharsetDecoder chardecoder, CharsetEncoder charencoder, MessageConstraints constraints, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, NHttpMessageParserFactory<HttpRequest> requestParserFactory, NHttpMessageWriterFactory<HttpResponse> responseWriterFactory) Creates new instance DefaultNHttpServerConnection given the underlying I/O session.DefaultNHttpServerConnection
(IOSession session, int buffersize, CharsetDecoder chardecoder, CharsetEncoder charencoder, MessageConstraints constraints) DefaultNHttpServerConnection
(IOSession session, HttpRequestFactory requestFactory, ByteBufferAllocator allocator, HttpParams params) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
consumeInput
(NHttpServerEventHandler handler) void
consumeInput
(NHttpServiceHandler handler) Triggered when the connection is ready to consume input.boolean
Returnstrue
if an HTTP response has been submitted to the client.void
produceOutput
(NHttpServerEventHandler handler) void
produceOutput
(NHttpServiceHandler handler) Triggered when the connection is ready to produce output.void
Resets output state.void
Resets input state.void
submitResponse
(HttpResponse response) Submits {link @HttpResponse} to be sent to the client.Methods inherited from class org.apache.http.impl.nio.NHttpConnectionBase
close, getContext, getHttpRequest, getHttpResponse, getLocalAddress, getLocalPort, getMetrics, getRemoteAddress, getRemotePort, getSocket, getSocketTimeout, getStatus, hasBufferedInput, hasBufferedOutput, isOpen, isStale, requestInput, requestOutput, setSocketTimeout, shutdown, suspendInput, suspendOutput, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.http.HttpConnection
close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdown
Methods inherited from interface org.apache.http.nio.IOControl
requestInput, requestOutput, shutdown, suspendInput, suspendOutput
Methods inherited from interface org.apache.http.nio.NHttpConnection
getContext, getHttpRequest, getHttpResponse, getStatus
-
Constructor Details
-
DefaultNHttpServerConnection
@Deprecated public DefaultNHttpServerConnection(IOSession session, HttpRequestFactory requestFactory, ByteBufferAllocator allocator, HttpParams params) Creates a new instance of this class given the underlying I/O session.- Parameters:
session
- the underlying I/O session.requestFactory
- HTTP request factory.allocator
- byte buffer allocator.params
- HTTP parameters.
-
DefaultNHttpServerConnection
public DefaultNHttpServerConnection(IOSession session, int buffersize, int fragmentSizeHint, ByteBufferAllocator allocator, CharsetDecoder chardecoder, CharsetEncoder charencoder, MessageConstraints constraints, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, NHttpMessageParserFactory<HttpRequest> requestParserFactory, NHttpMessageWriterFactory<HttpResponse> responseWriterFactory) Creates new instance DefaultNHttpServerConnection given the underlying I/O session.- Parameters:
session
- the underlying I/O session.buffersize
- buffer size. Must be a positive number.fragmentSizeHint
- fragment size hint.allocator
- memory allocator. Ifnull
HeapByteBufferAllocator.INSTANCE
will be used.chardecoder
- decoder to be used for decoding HTTP protocol elements. Ifnull
simple type cast will be used for byte to char conversion.charencoder
- encoder to be used for encoding HTTP protocol elements. Ifnull
simple type cast will be used for char to byte conversion.constraints
- Message constraints. Ifnull
MessageConstraints.DEFAULT
will be used.incomingContentStrategy
- incoming content length strategy. Ifnull
DisallowIdentityContentLengthStrategy.INSTANCE
will be used.outgoingContentStrategy
- outgoing content length strategy. Ifnull
StrictContentLengthStrategy.INSTANCE
will be used.requestParserFactory
- request parser factory. Ifnull
DefaultHttpRequestParserFactory.INSTANCE
will be used.responseWriterFactory
- response writer factory. Ifnull
DefaultHttpResponseWriterFactory.INSTANCE
will be used.- Since:
- 4.3
-
DefaultNHttpServerConnection
public DefaultNHttpServerConnection(IOSession session, int buffersize, CharsetDecoder chardecoder, CharsetEncoder charencoder, MessageConstraints constraints) - Since:
- 4.3
-
DefaultNHttpServerConnection
- Since:
- 4.3
-
-
Method Details
-
resetInput
public void resetInput()Description copied from interface:NHttpServerConnection
Resets output state. This method can be used to prematurely terminate processing of the incoming HTTP request.- Specified by:
resetInput
in interfaceNHttpServerConnection
-
resetOutput
public void resetOutput()Description copied from interface:NHttpServerConnection
Resets input state. This method can be used to prematurely terminate processing of the outgoing HTTP response.- Specified by:
resetOutput
in interfaceNHttpServerConnection
-
consumeInput
-
produceOutput
-
submitResponse
Description copied from interface:NHttpServerConnection
Submits {link @HttpResponse} to be sent to the client.- Specified by:
submitResponse
in interfaceNHttpServerConnection
- Parameters:
response
- HTTP response- Throws:
IOException
- if I/O error occurs while submitting the responseHttpException
- if the HTTP response violates the HTTP protocol.
-
isResponseSubmitted
public boolean isResponseSubmitted()Description copied from interface:NHttpServerConnection
Returnstrue
if an HTTP response has been submitted to the client.- Specified by:
isResponseSubmitted
in interfaceNHttpServerConnection
- Returns:
true
if an HTTP response has been submitted,false
otherwise.
-
consumeInput
Description copied from interface:NHttpServerIOTarget
Triggered when the connection is ready to consume input.- Specified by:
consumeInput
in interfaceNHttpServerIOTarget
- Parameters:
handler
- the server protocol handler.
-
produceOutput
Description copied from interface:NHttpServerIOTarget
Triggered when the connection is ready to produce output.- Specified by:
produceOutput
in interfaceNHttpServerIOTarget
- Parameters:
handler
- the server protocol handler.
-
DefaultNHttpServerConnection(IOSession, int, int, ByteBufferAllocator, CharsetDecoder, CharsetEncoder, MessageConstraints, ContentLengthStrategy, ContentLengthStrategy, NHttpMessageParserFactory, NHttpMessageWriterFactory)