Interface HttpAsyncExchange


  • public interface HttpAsyncExchange
    HttpAsyncExchange represents a server-side HTTP message exchange where an HTTP response can be deferred without blocking the I/O event thread and triggered asynchronously at a later point of later time.
    Since:
    4.2
    • Method Detail

      • getRequest

        HttpRequest getRequest()
        Returns the received HTTP request message.
        Returns:
        received HTTP request message.
      • getResponse

        HttpResponse getResponse()
        Returns the default HTTP response message. Once ready the response message can submitted using submitResponse() method.
        Returns:
        default HTTP response message.
      • submitResponse

        void submitResponse()
        Submits the default HTTP response and completed the message exchange. If the response encloses an HttpEntity instance the entity is also expected to implement the HttpAsyncContentProducer interface for efficient content streaming to a non-blocking HTTP connection.
        Throws:
        java.lang.IllegalStateException - if a response has already been submitted.
      • isCompleted

        boolean isCompleted()
        Determines whether or not the message exchange has been completed.
        Returns:
        true if the message exchange has been completed, false otherwise.
      • setCallback

        void setCallback​(Cancellable cancellable)
        Sets Cancellable callback to be invoked in case the underlying connection times out or gets terminated prematurely by the client. This callback can be used to cancel a long running response generating process if a response is no longer needed.
      • setTimeout

        void setTimeout​(int timeout)
        Sets timeout for this message exchange.
      • getTimeout

        int getTimeout()
        Returns timeout for this message exchange.