java.lang.Object | |||
↳ | com.ning.http.client.AsyncCompletionHandler<T> | ||
↳ | com.ning.http.client.AsyncCompletionHandlerBase | ||
↳ | com.ning.http.client.listener.TransferCompletionHandler |
A AsyncHandler
that can be used to notify a set of TransferListener
AsyncHttpClient client = new AsyncHttpClient(); TransferCompletionHandler tl = new TransferCompletionHandler(); tl.addTransferListener(new TransferListener() { public void onRequestHeadersSent(FluentCaseInsensitiveStringsMap headers) { } public void onResponseHeadersReceived(FluentCaseInsensitiveStringsMap headers) { } public void onBytesReceived(ByteBuffer buffer) { } public void onBytesSent(ByteBuffer buffer) { } public void onRequestResponseCompleted() { } public void onThrowable(Throwable t) { } }); Response response = httpClient.prepareGet("http://...").execute(tl).get();
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TransferCompletionHandler.TransferAdapter |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a TransferCompletionHandler that will not accumulate bytes.
| |||||||||||
Create a TransferCompletionHandler that can or cannot accumulate bytes and make it available when
getResponseBody() get called. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a
TransferListener | |||||||||||
Invoked as soon as some response body part are received.
| |||||||||||
Invoked once the HTTP response processing is finished.
| |||||||||||
Invoked when the content (a java.io.File, String or java.io.FileInputStream has been fully
written on the I/O socket.
| |||||||||||
Invoked when the I/O operation associated with the
Request body as been progressed.
| |||||||||||
Invoked when the content (a java.io.File, String or java.io.FileInputStream has been fully
written on the I/O socket.
| |||||||||||
Invoked as soon as the HTTP headers has been received.
| |||||||||||
Invoked when an unexpected exception occurs during the processing of the response.
| |||||||||||
Remove a
TransferListener | |||||||||||
Associate a
TransferCompletionHandler.TransferAdapter with this listener. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.ning.http.client.AsyncCompletionHandlerBase
| |||||||||||
From class
com.ning.http.client.AsyncCompletionHandler
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
com.ning.http.client.AsyncHandler
| |||||||||||
From interface
com.ning.http.client.ProgressAsyncHandler
|
Create a TransferCompletionHandler that will not accumulate bytes. The resulting getResponseBody()
,
getResponseBodyAsStream()
and getResponseBodyExcerpt(int)
will
throw an IllegalStateException if called.
Create a TransferCompletionHandler that can or cannot accumulate bytes and make it available when
getResponseBody()
get called. The default is false.
accumulateResponseBytes | true to accumulates bytes in memory. |
---|
Invoked as soon as some response body part are received. Could be invoked many times.
content | response's body part. |
---|
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.Exception |
---|
Invoked once the HTTP response processing is finished.
Gets always invoked as last callback method.response | The Response |
---|
Exception |
---|
Invoked when the content (a java.io.File, String or java.io.FileInputStream has been fully written on the I/O socket.
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
Invoked when the I/O operation associated with the Request
body as been progressed.
amount | The amount of bytes to transfer. |
---|---|
current | The amount of bytes transferred |
total | The total number of bytes transferred |
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
Invoked when the content (a java.io.File, String or java.io.FileInputStream has been fully written on the I/O socket.
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
Invoked as soon as the HTTP headers has been received. Can potentially be invoked more than once if a broken server sent trailing headers.
headers | the HTTP headers. |
---|
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.Exception |
---|
Invoked when an unexpected exception occurs during the processing of the response. The exception may have been produced by implementation of onXXXReceived method invocation.
t | a Throwable |
---|
Associate a TransferCompletionHandler.TransferAdapter
with this listener.
transferAdapter | TransferCompletionHandler.TransferAdapter
|
---|