Class HttpConnection

    • Field Detail


        public static final HttpField CONNECTION_CLOSE

        public static final java.lang.String UPGRADE_CONNECTION_ATTRIBUTE
        See Also:
        Constant Field Values
    • Method Detail

      • getCurrentConnection

        public static HttpConnection getCurrentConnection()
        Get the current connection that this thread is dispatched to. Note that a thread may be processing a request asynchronously and thus not be dispatched to the connection.
        the current HttpConnection or null
        See Also:
        for a more general way to access the HttpConnection
      • isRecordHttpComplianceViolations

        public boolean isRecordHttpComplianceViolations()
      • getServer

        public Server getServer()
      • getConnector

        public Connector getConnector()
      • isOptimizedForDirectBuffers

        public boolean isOptimizedForDirectBuffers()
        Description copied from interface: HttpTransport
        Is the underlying transport optimized for DirectBuffer usage
        Specified by:
        isOptimizedForDirectBuffers in interface HttpTransport
        True if direct buffers can be used optimally.
      • onUpgradeFrom

        public java.nio.ByteBuffer onUpgradeFrom()
        Description copied from interface: Connection.UpgradeFrom

        Takes the input buffer from the connection on upgrade.

        This method is used to take any unconsumed input from a connection during an upgrade.

        Specified by:
        onUpgradeFrom in interface Connection.UpgradeFrom
        A buffer of unconsumed input. The caller must return the buffer to the bufferpool when consumed and this connection must not.
      • onUpgradeTo

        public void onUpgradeTo​(java.nio.ByteBuffer buffer)
        Description copied from interface: Connection.UpgradeTo

        Callback method invoked when this connection is upgraded.

        This must be called before Connection.onOpen().

        Specified by:
        onUpgradeTo in interface Connection.UpgradeTo
        buffer - An optional buffer that can contain prefilled data. Typically this results from an upgrade of one protocol to the other where the old connection has buffered data destined for the new connection. The new connection must take ownership of the buffer and is responsible for returning it to the buffer pool
      • onFlushed

        public void onFlushed​(long bytes)
        Description copied from interface: WriteFlusher.Listener

        Invoked when a WriteFlusher flushed bytes in a non-blocking way, as part of a - possibly larger - write.

        This method may be invoked multiple times, for example when writing a large buffer: a first flush of bytes, then the connection became TCP congested, and a subsequent flush of bytes when the connection became writable again.

        This method is never invoked concurrently, but may be invoked by different threads, so implementations may not rely on thread-local variables.

        Implementations may throw an IOException to signal that the write should fail, for example if the implementation enforces a minimum data rate.

        Specified by:
        onFlushed in interface WriteFlusher.Listener
        bytes - the number of bytes flushed
        Throws: - if the write should fail
      • getRequestBuffer

        public java.nio.ByteBuffer getRequestBuffer()
      • isRequestBufferEmpty

        public boolean isRequestBufferEmpty()
      • fillAndParseForContent

        protected boolean fillAndParseForContent()
        Fill and parse data looking for content
        true if an HttpParser.RequestHandler method was called and it returned true;
      • onCompleted

        public void onCompleted()
        Description copied from interface: HttpTransport
        Called to indicated the end of the current request/response cycle (which may be some time after the last content is sent).
        Specified by:
        onCompleted in interface HttpTransport
      • onReadTimeout

        protected boolean onReadTimeout​(java.lang.Throwable timeout)
        Description copied from class: AbstractConnection

        Callback method invoked when the endpoint failed to be ready to be read after a timeout

        onReadTimeout in class AbstractConnection
        timeout - the cause of the read timeout
        true to signal that the endpoint must be closed, false to keep the endpoint open
      • onFillInterestedFailed

        protected void onFillInterestedFailed​(java.lang.Throwable cause)
        Description copied from class: AbstractConnection

        Callback method invoked when the endpoint failed to be ready to be read.

        onFillInterestedFailed in class AbstractConnection
        cause - the exception that caused the failure
      • onOpen

        public void onOpen()
        Description copied from interface: Connection

        Callback method invoked when this connection is opened.

        Creators of the connection implementation are responsible for calling this method.

        Specified by:
        onOpen in interface Connection
        onOpen in class AbstractConnection
      • onClose

        public void onClose()
        Description copied from interface: Connection

        Callback method invoked when this connection is closed.

        Creators of the connection implementation are responsible for calling this method.

        Specified by:
        onClose in interface Connection
        onClose in class AbstractConnection
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • send

        public void send​(MetaData.Response info,
                         boolean head,
                         java.nio.ByteBuffer content,
                         boolean lastContent,
                         Callback callback)
        Description copied from interface: HttpTransport
        Asynchronous call to send a response (or part) over the transport
        Specified by:
        send in interface HttpTransport
        info - The header info to send, or null if just sending more data. The first call to send for a response must have a non null info.
        head - True if the response if for a HEAD request (and the data should not be sent).
        content - A buffer of content to be sent.
        lastContent - True if the content is the last content for the current response.
        callback - The Callback instance that success or failure of the send is notified on
      • abort

        public void abort​(java.lang.Throwable failure)
        Description copied from interface: HttpTransport
        Aborts this transport.

        This method should terminate the transport in a way that can indicate an abnormal response to the client, for example by abruptly close the connection.

        This method is called when an error response needs to be sent, but the response is already committed, or when a write failure is detected. If abort is called, HttpTransport.onCompleted() is not called

        Specified by:
        abort in interface HttpTransport
        failure - the failure that caused the abort.
      • isPushSupported

        public boolean isPushSupported()
        Specified by:
        isPushSupported in interface HttpTransport
        true if responses can be pushed over this transport
      • push

        public void push​(MetaData.Request request)
        Specified by:
        push in interface HttpTransport
        request - A request to use as the basis for generating a pushed response.
      • asyncReadFillInterested

        public void asyncReadFillInterested()
      • blockingReadFillInterested

        public void blockingReadFillInterested()
      • blockingReadFailure

        public void blockingReadFailure​(java.lang.Throwable e)