Sending another asynchronous request from an AsyncHandler
must be done using
another thread to avoid potential deadlock inside the AsyncHttpProvider
The recommended way is to use the ExecutorService
from the AsyncHttpClientConfig
:
@Override
public T onCompleted() throws Exception
{
asyncHttpClient.getConfig().executorService().execute(new Runnable()
{
public void run()
{
asyncHttpClient.prepareGet(...);
}
});
return T;
}
onThrowable
void onThrowable(Throwable t)
- Invoked when an unexpected exception occurs during the processing of the response
- Parameters:
t
- a Throwable
onBodyPartReceived
AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart bodyPart)
throws Exception
- Invoked as soon as some response body part are received.
- Parameters:
bodyPart
- response's body part.
- Returns:
- a
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
- Throws:
Exception
- if something wrong happens
onStatusReceived
AsyncHandler.STATE onStatusReceived(HttpResponseStatus responseStatus)
throws Exception
- Invoked as soon as the HTTP status line has been received
- Parameters:
responseStatus
- the status code and test of the response
- Returns:
- a
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
- Throws:
Exception
- if something wrong happens
onHeadersReceived
AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers)
throws Exception
- Invoked as soon as the HTTP headers has been received.
- Parameters:
headers
- the HTTP headers.
- Returns:
- a
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
- Throws:
Exception
- if something wrong happens
onCompleted
T onCompleted()
throws Exception
- Invoked once the HTTP response has been fully received
- Returns:
- T Type of the value that will be returned by the associated
Future
- Throws:
Exception
- if something wrong happens
Copyright © 2010. All Rights Reserved.