Class NHttpConnectionBase

    • Field Detail

      • incomingContentStrategy

        protected final org.apache.http.entity.ContentLengthStrategy incomingContentStrategy
      • outgoingContentStrategy

        protected final org.apache.http.entity.ContentLengthStrategy outgoingContentStrategy
      • inTransportMetrics

        protected final org.apache.http.impl.io.HttpTransportMetricsImpl inTransportMetrics
      • outTransportMetrics

        protected final org.apache.http.impl.io.HttpTransportMetricsImpl outTransportMetrics
      • connMetrics

        protected final org.apache.http.impl.HttpConnectionMetricsImpl connMetrics
      • context

        protected org.apache.http.protocol.HttpContext context
      • remote

        protected java.net.SocketAddress remote
      • hasBufferedInput

        protected volatile boolean hasBufferedInput
      • hasBufferedOutput

        protected volatile boolean hasBufferedOutput
      • request

        protected volatile org.apache.http.HttpRequest request
      • response

        protected volatile org.apache.http.HttpResponse response
      • status

        protected volatile int status
    • Constructor Detail

      • NHttpConnectionBase

        protected NHttpConnectionBase​(IOSession session,
                                      int bufferSize,
                                      int fragmentSizeHint,
                                      ByteBufferAllocator allocator,
                                      java.nio.charset.CharsetDecoder charDecoder,
                                      java.nio.charset.CharsetEncoder charEncoder,
                                      org.apache.http.config.MessageConstraints constraints,
                                      org.apache.http.entity.ContentLengthStrategy incomingContentStrategy,
                                      org.apache.http.entity.ContentLengthStrategy outgoingContentStrategy)
        Creates new instance NHttpConnectionBase 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.4
      • NHttpConnectionBase

        protected NHttpConnectionBase​(IOSession session,
                                      int bufferSize,
                                      int fragmentSizeHint,
                                      ByteBufferAllocator allocator,
                                      java.nio.charset.CharsetDecoder charDecoder,
                                      java.nio.charset.CharsetEncoder charEncoder,
                                      org.apache.http.entity.ContentLengthStrategy incomingContentStrategy,
                                      org.apache.http.entity.ContentLengthStrategy outgoingContentStrategy)
        Creates new instance NHttpConnectionBase 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.
        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
    • Method Detail

      • bind

        protected void bind​(IOSession session)
        Binds the connection to a different IOSession. This may be necessary when the underlying I/O session gets upgraded with SSL/TLS encryption.
        Since:
        4.2
      • createIncomingContentStrategy

        @Deprecated
        protected org.apache.http.entity.ContentLengthStrategy createIncomingContentStrategy()
        Deprecated.
        (4.3) use constructor.
        Since:
        4.2
      • createOutgoingContentStrategy

        @Deprecated
        protected org.apache.http.entity.ContentLengthStrategy createOutgoingContentStrategy()
        Deprecated.
        (4.3) use constructor.
        Since:
        4.2
      • createTransportMetrics

        @Deprecated
        protected org.apache.http.impl.io.HttpTransportMetricsImpl createTransportMetrics()
        Deprecated.
        (4.3) no longer used.
        Since:
        4.1
      • createConnectionMetrics

        @Deprecated
        protected org.apache.http.impl.HttpConnectionMetricsImpl createConnectionMetrics​(org.apache.http.io.HttpTransportMetrics inTransportMetric,
                                                                                         org.apache.http.io.HttpTransportMetrics outTransportMetric)
        Deprecated.
        (4.3) use decorator to add additional metrics.
        Since:
        4.1
      • getContext

        public org.apache.http.protocol.HttpContext getContext()
        Description copied from interface: NHttpConnection
        Returns an HTTP execution context associated with this connection.
        Specified by:
        getContext in interface NHttpConnection
        Returns:
        HTTP context
      • getHttpRequest

        public org.apache.http.HttpRequest getHttpRequest()
        Description copied from interface: NHttpConnection
        Returns the current HTTP request if one is being received / transmitted. Otherwise returns null.
        Specified by:
        getHttpRequest in interface NHttpConnection
        Returns:
        HTTP request, if available, null otherwise.
      • getHttpResponse

        public org.apache.http.HttpResponse getHttpResponse()
        Description copied from interface: NHttpConnection
        Returns the current HTTP response if one is being received / transmitted. Otherwise returns null.
        Specified by:
        getHttpResponse in interface NHttpConnection
        Returns:
        HTTP response, if available, null otherwise.
      • requestInput

        public void requestInput()
        Description copied from interface: IOControl
        Requests event notifications to be triggered when the underlying channel is ready for input operations.
        Specified by:
        requestInput in interface IOControl
      • requestOutput

        public void requestOutput()
        Description copied from interface: IOControl
        Requests event notifications to be triggered when the underlying channel is ready for output operations.
        Specified by:
        requestOutput in interface IOControl
      • suspendInput

        public void suspendInput()
        Description copied from interface: IOControl
        Suspends event notifications about the underlying channel being ready for input operations.
        Specified by:
        suspendInput in interface IOControl
      • suspendOutput

        public void suspendOutput()
        Description copied from interface: IOControl
        Suspends event notifications about the underlying channel being ready for output operations.
        Specified by:
        suspendOutput in interface IOControl
      • prepareDecoder

        protected org.apache.http.HttpEntity prepareDecoder​(org.apache.http.HttpMessage message)
                                                     throws org.apache.http.HttpException
        Initializes a specific ContentDecoder implementation based on the properties of the given HttpMessage and generates an instance of HttpEntity matching the properties of the content decoder.
        Parameters:
        message - the HTTP message.
        Returns:
        HTTP entity.
        Throws:
        org.apache.http.HttpException - in case of an HTTP protocol violation.
      • createContentDecoder

        protected ContentDecoder createContentDecoder​(long len,
                                                      java.nio.channels.ReadableByteChannel channel,
                                                      SessionInputBuffer buffer,
                                                      org.apache.http.impl.io.HttpTransportMetricsImpl metrics)
        Factory method for ContentDecoder instances.
        Parameters:
        len - content length, if known, ContentLengthStrategy.CHUNKED or ContentLengthStrategy.IDENTITY, if unknown.
        channel - the session channel.
        buffer - the session buffer.
        metrics - transport metrics.
        Returns:
        content decoder.
        Since:
        4.1
      • prepareEncoder

        protected void prepareEncoder​(org.apache.http.HttpMessage message)
                               throws org.apache.http.HttpException
        Initializes a specific ContentEncoder implementation based on the properties of the given HttpMessage.
        Parameters:
        message - the HTTP message.
        Throws:
        org.apache.http.HttpException - in case of an HTTP protocol violation.
      • createContentEncoder

        protected ContentEncoder createContentEncoder​(long len,
                                                      java.nio.channels.WritableByteChannel channel,
                                                      SessionOutputBuffer buffer,
                                                      org.apache.http.impl.io.HttpTransportMetricsImpl metrics)
        Factory method for ContentEncoder instances.
        Parameters:
        len - content length, if known, ContentLengthStrategy.CHUNKED or ContentLengthStrategy.IDENTITY, if unknown.
        channel - the session channel.
        buffer - the session buffer.
        metrics - transport metrics.
        Returns:
        content encoder.
        Since:
        4.1
      • hasBufferedInput

        public boolean hasBufferedInput()
        Description copied from interface: SessionBufferStatus
        Determines if the session input buffer contains data.
        Specified by:
        hasBufferedInput in interface SessionBufferStatus
        Returns:
        true if the session input buffer contains data, false otherwise.
      • hasBufferedOutput

        public boolean hasBufferedOutput()
        Description copied from interface: SessionBufferStatus
        Determines if the session output buffer contains data.
        Specified by:
        hasBufferedOutput in interface SessionBufferStatus
        Returns:
        true if the session output buffer contains data, false otherwise.
      • assertNotClosed

        protected void assertNotClosed()
                                throws org.apache.http.ConnectionClosedException
        Assets if the connection is still open.
        Throws:
        org.apache.http.ConnectionClosedException - in case the connection has already been closed.
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface org.apache.http.HttpConnection
        Throws:
        java.io.IOException
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface org.apache.http.HttpConnection
      • isStale

        public boolean isStale()
        Specified by:
        isStale in interface org.apache.http.HttpConnection
      • getLocalAddress

        public java.net.InetAddress getLocalAddress()
        Specified by:
        getLocalAddress in interface org.apache.http.HttpInetConnection
      • getLocalPort

        public int getLocalPort()
        Specified by:
        getLocalPort in interface org.apache.http.HttpInetConnection
      • getRemoteAddress

        public java.net.InetAddress getRemoteAddress()
        Specified by:
        getRemoteAddress in interface org.apache.http.HttpInetConnection
      • getRemotePort

        public int getRemotePort()
        Specified by:
        getRemotePort in interface org.apache.http.HttpInetConnection
      • setSocketTimeout

        public void setSocketTimeout​(int timeout)
        Specified by:
        setSocketTimeout in interface org.apache.http.HttpConnection
      • getSocketTimeout

        public int getSocketTimeout()
        Specified by:
        getSocketTimeout in interface org.apache.http.HttpConnection
      • shutdown

        public void shutdown()
                      throws java.io.IOException
        Description copied from interface: IOControl
        Shuts down the underlying channel.
        Specified by:
        shutdown in interface org.apache.http.HttpConnection
        Specified by:
        shutdown in interface IOControl
        Throws:
        java.io.IOException - in an error occurs
      • getMetrics

        public org.apache.http.HttpConnectionMetrics getMetrics()
        Specified by:
        getMetrics in interface org.apache.http.HttpConnection
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getSocket

        public java.net.Socket getSocket()
        Description copied from interface: SocketAccessor
        Return the underlying socket
        Specified by:
        getSocket in interface SocketAccessor
        Returns:
        - the underlying Socket, may be null.