org.apache.http.nio.protocol

## Class HttpAsyncRequester

- java.lang.Object
- - org.apache.http.nio.protocol.HttpAsyncRequester

    @Immutable
    public class HttpAsyncRequester
    extends Object

`HttpAsyncRequester` is a utility class that can be used in conjunction with `HttpAsyncRequestExecutor` to initiate execution of asynchronous HTTP requests.

Since:
  4.2
See Also:
  `HttpAsyncRequestExecutor`

### Constructor Summary

Constructors
Constructor and Description
`HttpAsyncRequester(HttpProcessor httppocessor)` Creates new instance of HttpAsyncRequester.
`HttpAsyncRequester(HttpProcessor httppocessor, ConnectionReuseStrategy connReuseStrategy)` Creates new instance of HttpAsyncRequester.
`HttpAsyncRequester(HttpProcessor httppocessor, ConnectionReuseStrategy reuseStrategy, HttpParams params)` Deprecated. (4.3) use `HttpAsyncRequester(HttpProcessor, ConnectionReuseStrategy)`

### Method Summary

Methods
`<T,E extends PoolEntry<HttpHost,NHttpClientConnection>> Future<T>` `execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost,E> connPool)` Initiates asynchronous HTTP request execution.
`<T,E extends PoolEntry<HttpHost,NHttpClientConnection>> Future<T>` `execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost,E> connPool, HttpContext context)` Initiates asynchronous HTTP request execution.
`<T,E extends PoolEntry<HttpHost,NHttpClientConnection>> Future<T>` `execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost,E> connPool, HttpContext context, FutureCallback<T> callback)` Initiates asynchronous HTTP request execution.
`<T,E extends PoolEntry<HttpHost,NHttpClientConnection>> Future<T>` `execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, E poolEntry, ConnPool<HttpHost,E> connPool, HttpContext context, FutureCallback<T> callback)` Initiates asynchronous HTTP request execution.
`<T> Future<T>` `execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn)` Initiates asynchronous HTTP request execution.
`<T> Future<T>` `execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn, HttpContext context)` Initiates asynchronous HTTP request execution.
`<T> Future<T>` `execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn, HttpContext context, FutureCallback<T> callback)` Initiates asynchronous HTTP request execution.
`protected void` `log(Exception ex)` This method can be used to log I/O exception thrown while closing `Closeable` objects (such as `HttpConnection`}).

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### HttpAsyncRequester

    @Deprecated
    public HttpAsyncRequester(HttpProcessor httppocessor,
                                 ConnectionReuseStrategy reuseStrategy,
                                 HttpParams params)

Deprecated. (4.3) use `HttpAsyncRequester(HttpProcessor, ConnectionReuseStrategy)`

#### HttpAsyncRequester

    public HttpAsyncRequester(HttpProcessor httppocessor,
                      ConnectionReuseStrategy connReuseStrategy)

Creates new instance of HttpAsyncRequester.

Since:
  4.3

#### HttpAsyncRequester

    public HttpAsyncRequester(HttpProcessor httppocessor)

Creates new instance of HttpAsyncRequester.

Since:
  4.3

### Method Detail

#### execute

    public <T> Future<T> execute(HttpAsyncRequestProducer requestProducer,
                        HttpAsyncResponseConsumer<T> responseConsumer,
                        NHttpClientConnection conn,
                        HttpContext context,
                        FutureCallback<T> callback)

Initiates asynchronous HTTP request execution.

Type Parameters:
  `T` - the result type of request execution.
Parameters:
  `requestProducer` - request producer callback.
  `responseConsumer` - response consumer callaback.
  `conn` - underlying HTTP connection.
  `context` - HTTP context
  `callback` - future callback.
Returns:
  future representing pending completion of the operation.

#### execute

    public <T> Future<T> execute(HttpAsyncRequestProducer requestProducer,
                        HttpAsyncResponseConsumer<T> responseConsumer,
                        NHttpClientConnection conn,
                        HttpContext context)

Initiates asynchronous HTTP request execution.

Type Parameters:
  `T` - the result type of request execution.
Parameters:
  `requestProducer` - request producer callback.
  `responseConsumer` - response consumer callaback.
  `conn` - underlying HTTP connection.
  `context` - HTTP context
Returns:
  future representing pending completion of the operation.

#### execute

    public <T> Future<T> execute(HttpAsyncRequestProducer requestProducer,
                        HttpAsyncResponseConsumer<T> responseConsumer,
                        NHttpClientConnection conn)

Initiates asynchronous HTTP request execution.

Type Parameters:
  `T` - the result type of request execution.
Parameters:
  `requestProducer` - request producer callback.
  `responseConsumer` - response consumer callaback.
  `conn` - underlying HTTP connection.
Returns:
  future representing pending completion of the operation.

#### execute

    public <T,E extends PoolEntry<HttpHost,NHttpClientConnection>> Future<T> execute(HttpAsyncRequestProducer requestProducer,
                                                                            HttpAsyncResponseConsumer<T> responseConsumer,
                                                                            ConnPool<HttpHost,E> connPool,
                                                                            HttpContext context,
                                                                            FutureCallback<T> callback)

Initiates asynchronous HTTP request execution.

Type Parameters:
  `T` - the result type of request execution.
  `E` - the connection pool entry type.
Parameters:
  `requestProducer` - request producer callback.
  `responseConsumer` - response consumer callaback.
  `connPool` - pool of persistent reusable connections.
  `context` - HTTP context
  `callback` - future callback.
Returns:
  future representing pending completion of the operation.

#### execute

    public <T,E extends PoolEntry<HttpHost,NHttpClientConnection>> Future<T> execute(HttpAsyncRequestProducer requestProducer,
                                                                            HttpAsyncResponseConsumer<T> responseConsumer,
                                                                            E poolEntry,
                                                                            ConnPool<HttpHost,E> connPool,
                                                                            HttpContext context,
                                                                            FutureCallback<T> callback)

Initiates asynchronous HTTP request execution. This method automatically releases the given pool entry once request execution is completed (successfully or unsuccessfully).

Type Parameters:
  `T` - the result type of request execution.
  `E` - the connection pool entry type.
Parameters:
  `requestProducer` - request producer callback.
  `responseConsumer` - response consumer callaback.
  `poolEntry` - leased pool entry. It will be automatically released back to the pool when execution is completed.
  `connPool` - pool of persistent reusable connections.
  `context` - HTTP context
  `callback` - future callback.
Returns:
  future representing pending completion of the operation.
Since:
  4.3

#### execute

    public <T,E extends PoolEntry<HttpHost,NHttpClientConnection>> Future<T> execute(HttpAsyncRequestProducer requestProducer,
                                                                            HttpAsyncResponseConsumer<T> responseConsumer,
                                                                            ConnPool<HttpHost,E> connPool,
                                                                            HttpContext context)

Initiates asynchronous HTTP request execution.

Type Parameters:
  `T` - the result type of request execution.
  `E` - the connection pool entry type.
Parameters:
  `requestProducer` - request producer callback.
  `responseConsumer` - response consumer callaback.
  `connPool` - pool of persistent reusable connections.
  `context` - HTTP context
Returns:
  future representing pending completion of the operation.

#### execute

    public <T,E extends PoolEntry<HttpHost,NHttpClientConnection>> Future<T> execute(HttpAsyncRequestProducer requestProducer,
                                                                            HttpAsyncResponseConsumer<T> responseConsumer,
                                                                            ConnPool<HttpHost,E> connPool)

Initiates asynchronous HTTP request execution.

Type Parameters:
  `T` - the result type of request execution.
  `E` - the connection pool entry type.
Parameters:
  `requestProducer` - request producer callback.
  `responseConsumer` - response consumer callaback.
  `connPool` - pool of persistent reusable connections.
Returns:
  future representing pending completion of the operation.

#### log

    protected void log(Exception ex)

This method can be used to log I/O exception thrown while closing `Closeable` objects (such as `HttpConnection`}).

Parameters:
  `ex` - I/O exception thrown by `Closeable.close()`