java.lang.Object |
↳ |
com.ning.http.client.SimpleAsyncHttpClient |
Class Overview
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:
SimpleAsyncHttpClient 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));
or
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));
Summary
Nested Classes |
class |
SimpleAsyncHttpClient.Builder |
|
interface |
SimpleAsyncHttpClient.DerivedBuilder |
This interface contains possible configuration changes for a derived SimpleAsyncHttpClient. |
enum |
SimpleAsyncHttpClient.ErrorDocumentBehaviour |
|
Public Methods |
void
|
close()
Close the underlying AsyncHttpClient for this instance.
|
Future<Response>
|
delete()
|
Future<Response>
|
delete(BodyConsumer bodyConsumer)
|
Future<Response>
|
delete(BodyConsumer bodyConsumer, ThrowableHandler throwableHandler)
|
Future<Response>
|
delete(ThrowableHandler throwableHandler)
|
SimpleAsyncHttpClient.DerivedBuilder
|
derive()
Returns a Builder for a derived SimpleAsyncHttpClient that uses the same
instance of AsyncHttpClient to execute requests.
|
Future<Response>
|
get()
|
Future<Response>
|
get(BodyConsumer bodyConsumer)
|
Future<Response>
|
get(BodyConsumer bodyConsumer, ThrowableHandler throwableHandler)
|
Future<Response>
|
get(ThrowableHandler throwableHandler)
|
Future<Response>
|
head()
|
Future<Response>
|
head(ThrowableHandler throwableHandler)
|
Future<Response>
|
options()
|
Future<Response>
|
options(BodyConsumer bodyConsumer)
|
Future<Response>
|
options(BodyConsumer bodyConsumer, ThrowableHandler throwableHandler)
|
Future<Response>
|
options(ThrowableHandler throwableHandler)
|
Future<Response>
|
post(BodyConsumer consumer, Part... parts)
|
Future<Response>
|
post(BodyGenerator bodyGenerator)
|
Future<Response>
|
post(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer)
|
Future<Response>
|
post(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer, ThrowableHandler throwableHandler)
|
Future<Response>
|
post(BodyGenerator bodyGenerator, ThrowableHandler throwableHandler)
|
Future<Response>
|
post(Part... parts)
|
Future<Response>
|
put(BodyConsumer consumer, Part... parts)
|
Future<Response>
|
put(BodyGenerator bodyGenerator)
|
Future<Response>
|
put(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer)
|
Future<Response>
|
put(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer, ThrowableHandler throwableHandler)
|
Future<Response>
|
put(BodyGenerator bodyGenerator, ThrowableHandler throwableHandler)
|
Future<Response>
|
put(Part... parts)
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0)
|
final
void
|
wait(long arg0, int arg1)
|
|
Public Methods
public
void
close
()
Close the underlying AsyncHttpClient for this instance.
If this instance is derived from another instance, this method does
nothing as the client instance is managed by the original
SimpleAsyncHttpClient.
Returns a Builder for a derived SimpleAsyncHttpClient that uses the same
instance of 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.
Returns
- a Builder for a derived SimpleAsyncHttpClient that uses the same
instance of
AsyncHttpClient
to execute requests, never
null
.