Class DefaultNHttpClientConnection

java.lang.Object
org.apache.http.impl.nio.NHttpConnectionBase
org.apache.http.impl.nio.DefaultNHttpClientConnection
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.HttpConnection, org.apache.http.HttpInetConnection, IOControl, NHttpClientConnection, NHttpClientIOTarget, NHttpConnection, SessionBufferStatus, SocketAccessor

public class DefaultNHttpClientConnection extends NHttpConnectionBase implements NHttpClientIOTarget
Default implementation of the NHttpClientConnection interface.
Since:
4.0
  • Field Details

    • responseParser

      protected final NHttpMessageParser<org.apache.http.HttpResponse> responseParser
    • requestWriter

      protected final NHttpMessageWriter<org.apache.http.HttpRequest> requestWriter
  • Constructor Details

    • DefaultNHttpClientConnection

      @Deprecated public DefaultNHttpClientConnection(IOSession session, org.apache.http.HttpResponseFactory responseFactory, 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.
      responseFactory - HTTP response factory.
      allocator - byte buffer allocator.
      params - HTTP parameters.
    • DefaultNHttpClientConnection

      public DefaultNHttpClientConnection(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, NHttpMessageWriterFactory<org.apache.http.HttpRequest> requestWriterFactory, NHttpMessageParserFactory<org.apache.http.HttpResponse> responseParserFactory)
      Creates new instance DefaultNHttpClientConnection 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 LaxContentLengthStrategy.INSTANCE will be used.
      outgoingContentStrategy - outgoing content length strategy. If null StrictContentLengthStrategy.INSTANCE will be used.
      Since:
      4.3
    • DefaultNHttpClientConnection

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

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

    • createResponseParser

      @Deprecated protected NHttpMessageParser<org.apache.http.HttpResponse> createResponseParser(SessionInputBuffer buffer, org.apache.http.HttpResponseFactory responseFactory, 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 HttpResponse 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.
    • createRequestWriter

      @Deprecated protected NHttpMessageWriter<org.apache.http.HttpRequest> createRequestWriter(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 HttpRequest 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.
    • onResponseReceived

      protected void onResponseReceived(org.apache.http.HttpResponse response)
      Since:
      4.2
    • onRequestSubmitted

      protected void onRequestSubmitted(org.apache.http.HttpRequest request)
      Since:
      4.2
    • resetInput

      public void resetInput()
      Description copied from interface: NHttpClientConnection
      Resets input state. This method can be used to prematurely terminate processing of the incoming HTTP response.
      Specified by:
      resetInput in interface NHttpClientConnection
    • resetOutput

      public void resetOutput()
      Description copied from interface: NHttpClientConnection
      Resets output state. This method can be used to prematurely terminate processing of the outgoing HTTP request.
      Specified by:
      resetOutput in interface NHttpClientConnection
    • consumeInput

      public void consumeInput(NHttpClientEventHandler handler)
    • produceOutput

      public void produceOutput(NHttpClientEventHandler handler)
    • submitRequest

      public void submitRequest(org.apache.http.HttpRequest request) throws IOException, org.apache.http.HttpException
      Description copied from interface: NHttpClientConnection
      Submits HttpRequest to be sent to the target server.
      Specified by:
      submitRequest in interface NHttpClientConnection
      Parameters:
      request - HTTP request
      Throws:
      IOException - if I/O error occurs while submitting the request
      org.apache.http.HttpException - if the HTTP request violates the HTTP protocol.
    • isRequestSubmitted

      public boolean isRequestSubmitted()
      Description copied from interface: NHttpClientConnection
      Returns true if an HTTP request has been submitted to the target server.
      Specified by:
      isRequestSubmitted in interface NHttpClientConnection
      Returns:
      true if an HTTP request has been submitted, false otherwise.
    • consumeInput

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

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