public class SimpleAsyncHttpClient extends Object
AsyncHttpClient
and it's related builders (AsyncHttpClientConfig
,
Realm
, ProxyServer
and AsyncHandler
. You can
build powerful application by just using this class.
This class rely on BodyGenerator
and BodyConsumer
for handling the request and response body. No
AsyncHandler
are required. As simple as:
orSimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder() .setIdleConnectionInPoolTimeoutInMs(100) .setMaximumConnectionsTotal(50) .setRequestTimeoutInMs(5 * 60 * 1000) .setUrl(getTargetUrl()) .setHeader("Content-Type", "text/html").build(); StringBuilder s = new StringBuilder(); Futurefuture = client.post(new InputStreamBodyGenerator(new ByteArrayInputStream(MY_MESSAGE.getBytes())), new AppendableBodyConsumer(s));
public void ByteArrayOutputStreamBodyConsumerTest() throws Throwable { SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder() .setUrl(getTargetUrl()) .build(); ByteArrayOutputStream o = new ByteArrayOutputStream(10); Futurefuture = client.post(new FileodyGenerator(myFile), new OutputStreamBodyConsumer(o));
Modifier and Type | Class and Description |
---|---|
static class |
SimpleAsyncHttpClient.Builder |
static interface |
SimpleAsyncHttpClient.DerivedBuilder
This interface contains possible configuration changes for a derived SimpleAsyncHttpClient.
|
static class |
SimpleAsyncHttpClient.ErrorDocumentBehaviour |
public Future<Response> post(Part... parts) throws IOException
IOException
public Future<Response> post(BodyConsumer consumer, Part... parts) throws IOException
IOException
public Future<Response> post(BodyGenerator bodyGenerator) throws IOException
IOException
public Future<Response> post(BodyGenerator bodyGenerator, ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> post(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer) throws IOException
IOException
public Future<Response> post(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer, ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> put(Part... parts) throws IOException
IOException
public Future<Response> put(BodyConsumer consumer, Part... parts) throws IOException
IOException
public Future<Response> put(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer) throws IOException
IOException
public Future<Response> put(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer, ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> put(BodyGenerator bodyGenerator) throws IOException
IOException
public Future<Response> put(BodyGenerator bodyGenerator, ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> get() throws IOException
IOException
public Future<Response> get(ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> get(BodyConsumer bodyConsumer) throws IOException
IOException
public Future<Response> get(BodyConsumer bodyConsumer, ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> delete() throws IOException
IOException
public Future<Response> delete(ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> delete(BodyConsumer bodyConsumer) throws IOException
IOException
public Future<Response> delete(BodyConsumer bodyConsumer, ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> head() throws IOException
IOException
public Future<Response> head(ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> options() throws IOException
IOException
public Future<Response> options(ThrowableHandler throwableHandler) throws IOException
IOException
public Future<Response> options(BodyConsumer bodyConsumer) throws IOException
IOException
public Future<Response> options(BodyConsumer bodyConsumer, ThrowableHandler throwableHandler) throws IOException
IOException
public void close()
derive()
,
AsyncHttpClient.close()
public SimpleAsyncHttpClient.DerivedBuilder derive()
AsyncHttpClient
to execute requests.
The original SimpleAsyncHttpClient is responsible for managing the
underlying AsyncHttpClient. For the derived instance, close()
is
a NOOP. If the original SimpleAsyncHttpClient is closed, all derived
instances become invalid.AsyncHttpClient
to execute requests, never
null
.Copyright © 2014. All Rights Reserved.