@NotThreadSafe public class DefaultNHttpServerConnection extends NHttpConnectionBase implements NHttpServerIOTarget
NHttpServerConnection interface.
The following parameters can be used to customize the behavior of this class:
| Modifier and Type | Field and Description |
|---|---|
protected NHttpMessageParser<HttpRequest> |
requestParser |
protected NHttpMessageWriter<HttpResponse> |
responseWriter |
connMetrics, contentDecoder, contentEncoder, context, hasBufferedInput, hasBufferedOutput, inbuf, incomingContentStrategy, inTransportMetrics, outbuf, outgoingContentStrategy, outTransportMetrics, remote, request, response, session, statusACTIVE, CLOSED, CLOSING| Constructor and Description |
|---|
DefaultNHttpServerConnection(IOSession session,
HttpRequestFactory requestFactory,
ByteBufferAllocator allocator,
HttpParams params)
Creates a new instance of this class given the underlying I/O session.
|
| Modifier and Type | Method and Description |
|---|---|
void |
consumeInput(NHttpServerEventHandler handler) |
void |
consumeInput(NHttpServiceHandler handler)
Triggered when the connection is ready to consume input.
|
protected ContentLengthStrategy |
createIncomingContentStrategy() |
protected NHttpMessageParser<HttpRequest> |
createRequestParser(SessionInputBuffer buffer,
HttpRequestFactory requestFactory,
HttpParams params)
Creates an instance of
NHttpMessageParser to be used
by this connection for parsing incoming HttpRequest messages. |
protected NHttpMessageWriter<HttpResponse> |
createResponseWriter(SessionOutputBuffer buffer,
HttpParams params)
Creates an instance of
NHttpMessageWriter to be used
by this connection for writing out outgoing HttpResponse
messages. |
boolean |
isResponseSubmitted()
Returns
true if an HTTP response has been submitted to the
client. |
protected void |
onRequestReceived(HttpRequest request) |
protected void |
onResponseSubmitted(HttpResponse response) |
void |
produceOutput(NHttpServerEventHandler handler) |
void |
produceOutput(NHttpServiceHandler handler)
Triggered when the connection is ready to produce output.
|
void |
resetInput()
Resets output state.
|
void |
resetOutput()
Resets input state.
|
void |
submitResponse(HttpResponse response)
Submits {link @HttpResponse} to be sent to the client.
|
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, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetContext, getHttpRequest, getHttpResponse, getStatusclose, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdownrequestInput, requestOutput, shutdown, suspendInput, suspendOutputprotected final NHttpMessageParser<HttpRequest> requestParser
protected final NHttpMessageWriter<HttpResponse> responseWriter
public DefaultNHttpServerConnection(IOSession session, HttpRequestFactory requestFactory, ByteBufferAllocator allocator, HttpParams params)
session - the underlying I/O session.requestFactory - HTTP request factory.allocator - byte buffer allocator.params - HTTP parameters.protected ContentLengthStrategy createIncomingContentStrategy()
createIncomingContentStrategy in class NHttpConnectionBaseprotected NHttpMessageParser<HttpRequest> createRequestParser(SessionInputBuffer buffer, HttpRequestFactory requestFactory, HttpParams params)
NHttpMessageParser to be used
by this connection for parsing incoming HttpRequest messages.
This method can be overridden in a super class in order to provide
a different implementation of the NHttpMessageParser interface.
protected NHttpMessageWriter<HttpResponse> createResponseWriter(SessionOutputBuffer buffer, HttpParams params)
NHttpMessageWriter to be used
by this connection for writing out outgoing HttpResponse
messages.
This method can be overridden by a super class in order to provide
a different implementation of the NHttpMessageWriter interface.
protected void onRequestReceived(HttpRequest request)
protected void onResponseSubmitted(HttpResponse response)
public void resetInput()
NHttpServerConnectionresetInput in interface NHttpServerConnectionpublic void resetOutput()
NHttpServerConnectionresetOutput in interface NHttpServerConnectionpublic void consumeInput(NHttpServerEventHandler handler)
public void produceOutput(NHttpServerEventHandler handler)
public void submitResponse(HttpResponse response) throws IOException, HttpException
NHttpServerConnectionsubmitResponse in interface NHttpServerConnectionresponse - HTTP responseIOException - if I/O error occurs while submitting the responseHttpException - if the HTTP response violates the HTTP protocol.public boolean isResponseSubmitted()
NHttpServerConnectiontrue if an HTTP response has been submitted to the
client.isResponseSubmitted in interface NHttpServerConnectiontrue if an HTTP response has been submitted,
false otherwise.public void consumeInput(NHttpServiceHandler handler)
NHttpServerIOTargetconsumeInput in interface NHttpServerIOTargethandler - the server protocol handler.public void produceOutput(NHttpServiceHandler handler)
NHttpServerIOTargetproduceOutput in interface NHttpServerIOTargethandler - the server protocol handler.Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.