|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ning.http.client.SimpleAsyncHttpClient
public class SimpleAsyncHttpClient
Simple implementation of 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(); Future
future = 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); Future
future = client.post(new FileodyGenerator(myFile), new OutputStreamBodyConsumer(o));
Nested Class Summary | |
---|---|
static class |
SimpleAsyncHttpClient.Builder
|
static interface |
SimpleAsyncHttpClient.DerivedBuilder
This interface contains possible configuration changes for a derived SimpleAsyncHttpClient. |
static class |
SimpleAsyncHttpClient.ErrorDocumentBehaviour
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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()
If this instance is derived from another instance, this method does nothing as the client instance is managed by the original SimpleAsyncHttpClient.
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
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |