public class DefaultNHttpServerConnection extends NHttpConnectionBase implements NHttpServerIOTarget
NHttpServerConnection
interface.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, status
ACTIVE, CLOSED, CLOSING
Constructor and Description |
---|
DefaultNHttpServerConnection(IOSession session,
HttpRequestFactory requestFactory,
ByteBufferAllocator allocator,
HttpParams params)
|
DefaultNHttpServerConnection(IOSession session,
int buffersize) |
DefaultNHttpServerConnection(IOSession session,
int buffersize,
CharsetDecoder chardecoder,
CharsetEncoder charencoder,
MessageConstraints constraints) |
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.
|
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()
Deprecated.
(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.
|
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, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getContext, getHttpRequest, getHttpResponse, getStatus
close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdown
requestInput, requestOutput, shutdown, suspendInput, suspendOutput
protected final NHttpMessageParser<HttpRequest> requestParser
protected final NHttpMessageWriter<HttpResponse> responseWriter
@Deprecated 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.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)
session
- the underlying I/O session.buffersize
- buffer size. Must be a positive number.fragmentSizeHint
- fragment size hint.allocator
- memory allocator.
If null
HeapByteBufferAllocator.INSTANCE
will be used.chardecoder
- decoder to be used for decoding HTTP protocol elements.
If null
simple type cast will be used for byte to char conversion.charencoder
- encoder to be used for encoding HTTP protocol elements.
If null
simple type cast will be used for char to byte conversion.constraints
- Message constraints. If null
MessageConstraints.DEFAULT
will be used.incomingContentStrategy
- incoming content length strategy. If null
DisallowIdentityContentLengthStrategy.INSTANCE
will be used.outgoingContentStrategy
- outgoing content length strategy. If null
StrictContentLengthStrategy.INSTANCE
will be used.requestParserFactory
- request parser factory. If null
DefaultHttpRequestParserFactory.INSTANCE
will be used.responseWriterFactory
- response writer factory. If null
DefaultHttpResponseWriterFactory.INSTANCE
will be used.public DefaultNHttpServerConnection(IOSession session, int buffersize, CharsetDecoder chardecoder, CharsetEncoder charencoder, MessageConstraints constraints)
public DefaultNHttpServerConnection(IOSession session, int buffersize)
@Deprecated protected ContentLengthStrategy createIncomingContentStrategy()
createIncomingContentStrategy
in class NHttpConnectionBase
@Deprecated protected 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.
@Deprecated 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()
NHttpServerConnection
resetInput
in interface NHttpServerConnection
public void resetOutput()
NHttpServerConnection
resetOutput
in interface NHttpServerConnection
public void consumeInput(NHttpServerEventHandler handler)
public void produceOutput(NHttpServerEventHandler handler)
public void submitResponse(HttpResponse response) throws IOException, HttpException
NHttpServerConnection
submitResponse
in interface NHttpServerConnection
response
- HTTP responseIOException
- if I/O error occurs while submitting the responseHttpException
- if the HTTP response violates the HTTP protocol.public boolean isResponseSubmitted()
NHttpServerConnection
true
if an HTTP response has been submitted to the
client.isResponseSubmitted
in interface NHttpServerConnection
true
if an HTTP response has been submitted,
false
otherwise.public void consumeInput(NHttpServiceHandler handler)
NHttpServerIOTarget
consumeInput
in interface NHttpServerIOTarget
handler
- the server protocol handler.public void produceOutput(NHttpServiceHandler handler)
NHttpServerIOTarget
produceOutput
in interface NHttpServerIOTarget
handler
- the server protocol handler.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses