org.apache.http.nio.protocol

## 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 Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `HttpRequest` | `getRequest()` Returns the received HTTP request message.
    `HttpResponse` | `getResponse()` Returns the default HTTP response message.
    `int` | `getTimeout()` Returns timeout for this message exchange.
    `boolean` | `isCompleted()` Determines whether or not the message exchange has been completed.
    `void` | `setCallback(Cancellable cancellable)` Sets `Cancellable` callback to be invoked in case the underlying connection times out or gets terminated prematurely by the client.
    `void` | `setTimeout(int timeout)` Sets timeout for this message exchange.
    `void` | `submitResponse()` Submits the default HTTP response and completed the message exchange.
    `void` | `submitResponse(HttpAsyncResponseProducer responseProducer)` Submits an HTTP response using a custom `HttpAsyncResponseProducer`.

- - ### 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:
        `IllegalStateException` - if a response has already been submitted.

    - #### submitResponse

          void submitResponse(HttpAsyncResponseProducer responseProducer)

      Submits an HTTP response using a custom `HttpAsyncResponseProducer`.
      Throws:
        `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.

Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.