| com.ning.http.client.AsyncHandler<T> |
Known Indirect Subclasses
|
Class Overview
An asynchronous handler or callback which gets invoked as soon as some data is available when
processing an asynchronous response.
Callback methods get invoked in the following order:
onStatusReceived(HttpResponseStatus),
onHeadersReceived(HttpResponseHeaders),
onBodyPartReceived(HttpResponseBodyPart), which could be invoked multiple times,
onCompleted(), once the response has been fully read.
Returning a
ABORT from any of those callback methods will interrupt asynchronous response
processing, after that only
onCompleted() is going to be called.
AsyncHandler aren't thread safe, hence you should avoid re-using the same instance when doing concurrent requests.
As an exmaple, the following may produce unexpected results:
AsyncHandler ah = new AsyncHandler() {....};
AsyncHttpClient client = new AsyncHttpClient();
client.prepareGet("http://...").execute(ah);
client.prepareGet("http://...").execute(ah);
It is recommended to create a new instance instead.
Summary
| Nested Classes |
|
enum |
AsyncHandler.STATE |
|
Public Methods
Invoked as soon as some response body part are received. Could be invoked many times.
Parameters
| bodyPart
| response's body part. |
Throws
| Exception
| if something wrong happens
|
public
abstract
T
onCompleted
()
Invoked once the HTTP response processing is finished.
Gets always invoked as last callback method.
Returns
- T Value that will be returned by the associated java.util.concurrent.Future
Throws
| Exception
| if something wrong happens
|
Invoked as soon as the HTTP headers has been received. Can potentially be invoked more than once if a broken server
sent trailing headers.
Parameters
| headers
| the HTTP headers. |
Throws
| Exception
| if something wrong happens
|
Invoked as soon as the HTTP status line has been received
Parameters
| responseStatus
| the status code and test of the response |
Throws
| Exception
| if something wrong happens
|
public
abstract
void
onThrowable
(Throwable t)
Invoked when an unexpected exception occurs during the processing of the response. The exception may have been
produced by implementation of onXXXReceived method invocation.