Interface HttpAsyncRequestConsumer<T>

  • Type Parameters:
    T - the result type of request processing.
    All Superinterfaces:
    AutoCloseable, Closeable
    All Known Implementing Classes:
    AbstractAsyncRequestConsumer, BasicAsyncRequestConsumer

    public interface HttpAsyncRequestConsumer<T>
    extends Closeable
    HttpAsyncRequestConsumer is a callback interface whose methods get invoked to process an HTTP request message and to stream message content from a non-blocking HTTP connection on the server side.
    • Method Detail

      • consumeContent

        void consumeContent​(ContentDecoder decoder,
                            IOControl ioctrl)
                     throws IOException
        Invoked to process a chunk of content from the ContentDecoder. The IOControl interface can be used to suspend input event notifications if the consumer is temporarily unable to process content.

        The consumer can use the ContentDecoder.isCompleted() method to find out whether or not the message content has been fully consumed.

        Please note that the ContentDecoder object is not thread-safe and should only be used within the context of this method call. The IOControl object can be shared and used on other thread to resume input event notifications when the consumer is capable of processing more content.

        decoder - content decoder.
        ioctrl - I/O control of the underlying connection.
        IOException - in case of an I/O error
      • requestCompleted

        void requestCompleted​(HttpContext context)
        Invoked to signal that the request has been fully processed.
        context - HTTP context
      • failed

        void failed​(Exception ex)
        Invoked to signal that the request processing terminated abnormally.
        ex - exception
      • getException

        Exception getException()
        Returns an exception in case of an abnormal termination. This method returns null if the request execution is still ongoing or if it completed successfully.
        See Also:
      • getResult

        T getResult()
        Returns a result of the request execution, when available. This method returns null if the request execution is still ongoing.
        See Also:
      • isDone

        boolean isDone()
        Determines whether or not the request execution completed. If the request processing terminated normally getResult() can be used to obtain the result. If the request processing terminated abnormally getException() can be used to obtain the cause.