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
FieldsModifier and TypeFieldDescriptionprotected final NHttpMessageParser<HttpRequest> protected final NHttpMessageWriter<HttpResponse> Fields inherited from class org.apache.http.impl.nio.NHttpConnectionBase
connMetrics, contentDecoder, contentEncoder, context, hasBufferedInput, hasBufferedOutput, inbuf, incomingContentStrategy, inTransportMetrics, outbuf, outgoingContentStrategy, outTransportMetrics, remote, request, response, session, statusFields 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 TypeMethodDescriptionvoidconsumeInput(NHttpServerEventHandler handler) voidconsumeInput(NHttpServiceHandler handler) Triggered when the connection is ready to consume input.protected ContentLengthStrategyDeprecated.(4.3) use constructor.protected NHttpMessageParser<HttpRequest> createRequestParser(SessionInputBuffer buffer, HttpRequestFactory requestFactory, HttpParams params) Deprecated.(4.3) use constructor.protected NHttpMessageWriter<HttpResponse> createResponseWriter(SessionOutputBuffer buffer, HttpParams params) Deprecated.(4.3) use constructor.booleanReturnstrueif an HTTP response has been submitted to the client.protected voidonRequestReceived(HttpRequest request) protected voidonResponseSubmitted(HttpResponse response) voidproduceOutput(NHttpServerEventHandler handler) voidproduceOutput(NHttpServiceHandler handler) Triggered when the connection is ready to produce output.voidResets output state.voidResets input state.voidsubmitResponse(HttpResponse response) Submits {link @HttpResponse} to be sent to the client.Methods inherited from class org.apache.http.impl.nio.NHttpConnectionBase
assertNotClosed, bind, close, createConnectionMetrics, createContentDecoder, createContentEncoder, createOutgoingContentStrategy, createTransportMetrics, getContext, getHttpRequest, getHttpResponse, getLocalAddress, getLocalPort, getMetrics, getRemoteAddress, getRemotePort, getSocket, getSocketTimeout, getStatus, hasBufferedInput, hasBufferedOutput, isOpen, isStale, prepareDecoder, prepareEncoder, requestInput, requestOutput, setSocketTimeout, shutdown, suspendInput, suspendOutput, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.http.HttpConnection
close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdownMethods inherited from interface org.apache.http.nio.IOControl
requestInput, requestOutput, shutdown, suspendInput, suspendOutputMethods inherited from interface org.apache.http.nio.NHttpConnection
getContext, getHttpRequest, getHttpResponse, getStatus
-
Field Details
-
requestParser
-
responseWriter
-
-
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. IfnullHeapByteBufferAllocator.INSTANCEwill be used.charDecoder- decoder to be used for decoding HTTP protocol elements. Ifnullsimple type cast will be used for byte to char conversion.charEncoder- encoder to be used for encoding HTTP protocol elements. Ifnullsimple type cast will be used for char to byte conversion.constraints- Message constraints. IfnullMessageConstraints.DEFAULTwill be used.incomingContentStrategy- incoming content length strategy. IfnullDisallowIdentityContentLengthStrategy.INSTANCEwill be used.outgoingContentStrategy- outgoing content length strategy. IfnullStrictContentLengthStrategy.INSTANCEwill be used.requestParserFactory- request parser factory. IfnullDefaultHttpRequestParserFactory.INSTANCEwill be used.responseWriterFactory- response writer factory. IfnullDefaultHttpResponseWriterFactory.INSTANCEwill 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
-
createIncomingContentStrategy
Deprecated.(4.3) use constructor.- Overrides:
createIncomingContentStrategyin classNHttpConnectionBase
-
createRequestParser
@Deprecated protected NHttpMessageParser<HttpRequest> createRequestParser(SessionInputBuffer buffer, HttpRequestFactory requestFactory, HttpParams params) Deprecated.(4.3) use constructor.Creates an instance ofNHttpMessageParserto be used by this connection for parsing incomingHttpRequestmessages.This method can be overridden in a super class in order to provide a different implementation of the
NHttpMessageParserinterface.- Returns:
- HTTP response parser.
-
createResponseWriter
@Deprecated protected NHttpMessageWriter<HttpResponse> createResponseWriter(SessionOutputBuffer buffer, HttpParams params) Deprecated.(4.3) use constructor.Creates an instance ofNHttpMessageWriterto be used by this connection for writing out outgoingHttpResponsemessages.This method can be overridden by a super class in order to provide a different implementation of the
NHttpMessageWriterinterface.- Returns:
- HTTP response parser.
-
onRequestReceived
- Since:
- 4.2
-
onResponseSubmitted
- Since:
- 4.2
-
resetInput
public void resetInput()Description copied from interface:NHttpServerConnectionResets output state. This method can be used to prematurely terminate processing of the incoming HTTP request.- Specified by:
resetInputin interfaceNHttpServerConnection
-
resetOutput
public void resetOutput()Description copied from interface:NHttpServerConnectionResets input state. This method can be used to prematurely terminate processing of the outgoing HTTP response.- Specified by:
resetOutputin interfaceNHttpServerConnection
-
consumeInput
-
produceOutput
-
submitResponse
Description copied from interface:NHttpServerConnectionSubmits {link @HttpResponse} to be sent to the client.- Specified by:
submitResponsein 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:NHttpServerConnectionReturnstrueif an HTTP response has been submitted to the client.- Specified by:
isResponseSubmittedin interfaceNHttpServerConnection- Returns:
trueif an HTTP response has been submitted,falseotherwise.
-
consumeInput
Description copied from interface:NHttpServerIOTargetTriggered when the connection is ready to consume input.- Specified by:
consumeInputin interfaceNHttpServerIOTarget- Parameters:
handler- the server protocol handler.
-
produceOutput
Description copied from interface:NHttpServerIOTargetTriggered when the connection is ready to produce output.- Specified by:
produceOutputin interfaceNHttpServerIOTarget- Parameters:
handler- the server protocol handler.
-
DefaultNHttpServerConnection(IOSession, int, int, ByteBufferAllocator, CharsetDecoder, CharsetEncoder, MessageConstraints, ContentLengthStrategy, ContentLengthStrategy, NHttpMessageParserFactory, NHttpMessageWriterFactory)