Class DefaultNHttpServerConnection

java.lang.Object
org.apache.http.impl.nio.NHttpConnectionBase
org.apache.http.impl.nio.DefaultNHttpServerConnection
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.HttpConnection, org.apache.http.HttpInetConnection, IOControl, NHttpConnection, NHttpServerConnection, NHttpServerIOTarget, SessionBufferStatus, SocketAccessor

public class DefaultNHttpServerConnection extends NHttpConnectionBase implements NHttpServerIOTarget
Default implementation of the NHttpServerConnection interface.
Since:
4.0
  • Field Details

    • requestParser

      protected final NHttpMessageParser<org.apache.http.HttpRequest> requestParser
    • responseWriter

      protected final NHttpMessageWriter<org.apache.http.HttpResponse> responseWriter
  • Constructor Details

    • DefaultNHttpServerConnection

      @Deprecated public DefaultNHttpServerConnection(IOSession session, org.apache.http.HttpRequestFactory requestFactory, ByteBufferAllocator allocator, org.apache.http.params.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, org.apache.http.config.MessageConstraints constraints, org.apache.http.entity.ContentLengthStrategy incomingContentStrategy, org.apache.http.entity.ContentLengthStrategy outgoingContentStrategy, NHttpMessageParserFactory<org.apache.http.HttpRequest> requestParserFactory, NHttpMessageWriterFactory<org.apache.http.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. 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.
      Since:
      4.3
    • DefaultNHttpServerConnection

      public DefaultNHttpServerConnection(IOSession session, int bufferSize, CharsetDecoder charDecoder, CharsetEncoder charEncoder, org.apache.http.config.MessageConstraints constraints)
      Since:
      4.3
    • DefaultNHttpServerConnection

      public DefaultNHttpServerConnection(IOSession session, int bufferSize)
      Since:
      4.3
  • Method Details

    • createIncomingContentStrategy

      @Deprecated protected org.apache.http.entity.ContentLengthStrategy createIncomingContentStrategy()
      Deprecated.
      (4.3) use constructor.
      Overrides:
      createIncomingContentStrategy in class NHttpConnectionBase
    • createRequestParser

      @Deprecated protected NHttpMessageParser<org.apache.http.HttpRequest> createRequestParser(SessionInputBuffer buffer, org.apache.http.HttpRequestFactory requestFactory, org.apache.http.params.HttpParams params)
      Deprecated.
      (4.3) use constructor.
      Creates an instance of 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.

      Returns:
      HTTP response parser.
    • createResponseWriter

      @Deprecated protected NHttpMessageWriter<org.apache.http.HttpResponse> createResponseWriter(SessionOutputBuffer buffer, org.apache.http.params.HttpParams params)
      Deprecated.
      (4.3) use constructor.
      Creates an instance of 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.

      Returns:
      HTTP response parser.
    • onRequestReceived

      protected void onRequestReceived(org.apache.http.HttpRequest request)
      Since:
      4.2
    • onResponseSubmitted

      protected void onResponseSubmitted(org.apache.http.HttpResponse response)
      Since:
      4.2
    • 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 interface NHttpServerConnection
    • 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 interface NHttpServerConnection
    • consumeInput

      public void consumeInput(NHttpServerEventHandler handler)
    • produceOutput

      public void produceOutput(NHttpServerEventHandler handler)
    • submitResponse

      public void submitResponse(org.apache.http.HttpResponse response) throws IOException, org.apache.http.HttpException
      Description copied from interface: NHttpServerConnection
      Submits {link @HttpResponse} to be sent to the client.
      Specified by:
      submitResponse in interface NHttpServerConnection
      Parameters:
      response - HTTP response
      Throws:
      IOException - if I/O error occurs while submitting the response
      org.apache.http.HttpException - if the HTTP response violates the HTTP protocol.
    • isResponseSubmitted

      public boolean isResponseSubmitted()
      Description copied from interface: NHttpServerConnection
      Returns true if an HTTP response has been submitted to the client.
      Specified by:
      isResponseSubmitted in interface NHttpServerConnection
      Returns:
      true if an HTTP response has been submitted, false otherwise.
    • consumeInput

      public void consumeInput(NHttpServiceHandler handler)
      Description copied from interface: NHttpServerIOTarget
      Triggered when the connection is ready to consume input.
      Specified by:
      consumeInput in interface NHttpServerIOTarget
      Parameters:
      handler - the server protocol handler.
    • produceOutput

      public void produceOutput(NHttpServiceHandler handler)
      Description copied from interface: NHttpServerIOTarget
      Triggered when the connection is ready to produce output.
      Specified by:
      produceOutput in interface NHttpServerIOTarget
      Parameters:
      handler - the server protocol handler.