T
- Type of object returned by the Future.get()
public interface AsyncHandler<T>
onStatusReceived(HttpResponseStatus)
,onHeadersReceived(HttpResponseHeaders)
,onBodyPartReceived(HttpResponseBodyPart)
, which could be invoked multiple times,onCompleted()
, once the response has been fully read.AsyncHandler.State.ABORT
from any of those callback methods will interrupt asynchronous response
processing, after that only onCompleted()
is going to be called.
It is recommended to create a new instance instead. Do NOT perform any blocking operation in there, typically trying to send another request and call get() on its future. There's a chance you might end up in a dead lock. If you really to perform blocking operation, executed it in a different dedicated thread pool.AsyncHandler ah = new AsyncHandler() {....}; AsyncHttpClient client = new AsyncHttpClient(); client.prepareGet("http://...").execute(ah); client.prepareGet("http://...").execute(ah);
Modifier and Type | Interface and Description |
---|---|
static class |
AsyncHandler.State |
Modifier and Type | Method and Description |
---|---|
AsyncHandler.State |
onBodyPartReceived(HttpResponseBodyPart bodyPart)
Invoked as soon as some response body part are received.
|
T |
onCompleted()
Invoked once the HTTP response processing is finished.
|
AsyncHandler.State |
onHeadersReceived(HttpResponseHeaders headers)
Invoked as soon as the HTTP headers has been received.
|
AsyncHandler.State |
onStatusReceived(HttpResponseStatus responseStatus)
Invoked as soon as the HTTP status line has been received
|
void |
onThrowable(java.lang.Throwable t)
Invoked when an unexpected exception occurs during the processing of the response.
|
void onThrowable(java.lang.Throwable t)
t
- a Throwable
AsyncHandler.State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws java.lang.Exception
bodyPart
- response's body part.AsyncHandler.State
telling to CONTINUE or ABORT the current processing. Aborting will also close the connection.java.lang.Exception
- if something wrong happensAsyncHandler.State onStatusReceived(HttpResponseStatus responseStatus) throws java.lang.Exception
responseStatus
- the status code and test of the responseAsyncHandler.State
telling to CONTINUE or ABORT the current processing.java.lang.Exception
- if something wrong happensAsyncHandler.State onHeadersReceived(HttpResponseHeaders headers) throws java.lang.Exception
headers
- the HTTP headers.AsyncHandler.State
telling to CONTINUE or ABORT the current processing.java.lang.Exception
- if something wrong happensT onCompleted() throws java.lang.Exception
Future
java.lang.Exception
- if something wrong happensCopyright © 2018. All Rights Reserved.