|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ning.http.client.AsyncCompletionHandler<Response> com.ning.http.client.AsyncCompletionHandlerBase com.ning.http.client.listener.TransferCompletionHandler
public class 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 Class Summary | |
---|---|
static class |
TransferCompletionHandler.TransferAdapter
|
Nested classes/interfaces inherited from interface com.ning.http.client.AsyncHandler |
---|
AsyncHandler.STATE |
Constructor Summary | |
---|---|
TransferCompletionHandler()
Create a TransferCompletionHandler that will not accumulate bytes. |
|
TransferCompletionHandler(boolean accumulateResponseBytes)
Create a TransferCompletionHandler that can or cannot accumulate bytes and make it available when Response.getResponseBody() get called. |
Method Summary | |
---|---|
TransferCompletionHandler |
addTransferListener(TransferListener t)
Add a TransferListener |
AsyncHandler.STATE |
onBodyPartReceived(HttpResponseBodyPart content)
Invoked as soon as some response body part are received. |
Response |
onCompleted(Response response)
Invoked once the HTTP response processing is finished. |
AsyncHandler.STATE |
onContentWriteCompleted()
Invoked when the content (a File , String or FileInputStream has been fully
written on the I/O socket. |
AsyncHandler.STATE |
onContentWriteProgress(long amount,
long current,
long total)
Invoked when the I/O operation associated with the Request body as been progressed. |
AsyncHandler.STATE |
onHeadersReceived(HttpResponseHeaders headers)
Invoked as soon as the HTTP headers has been received. |
AsyncHandler.STATE |
onHeaderWriteCompleted()
Invoked when the content (a File , String or FileInputStream has been fully
written on the I/O socket. |
void |
onThrowable(Throwable t)
Invoked when an unexpected exception occurs during the processing of the response. |
TransferCompletionHandler |
removeTransferListener(TransferListener t)
Remove a TransferListener |
void |
transferAdapter(TransferCompletionHandler.TransferAdapter transferAdapter)
Associate a TransferCompletionHandler.TransferAdapter with this listener. |
Methods inherited from class com.ning.http.client.AsyncCompletionHandler |
---|
onCompleted, onStatusReceived |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TransferCompletionHandler()
Response.getResponseBody()
,
Response.getResponseBodyAsStream()
and Response.getResponseBodyExcerpt(int)
will
throw an IllegalStateException if called.
public TransferCompletionHandler(boolean accumulateResponseBytes)
Response.getResponseBody()
get called. The default is false.
accumulateResponseBytes
- true to accumulates bytes in memory.Method Detail |
---|
public TransferCompletionHandler addTransferListener(TransferListener t)
TransferListener
t
- a TransferListener
public TransferCompletionHandler removeTransferListener(TransferListener t)
TransferListener
t
- a TransferListener
public void transferAdapter(TransferCompletionHandler.TransferAdapter transferAdapter)
TransferCompletionHandler.TransferAdapter
with this listener.
transferAdapter
- TransferCompletionHandler.TransferAdapter
public AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers) throws Exception
onHeadersReceived
in interface AsyncHandler<Response>
onHeadersReceived
in class AsyncCompletionHandler<Response>
headers
- the HTTP headers.
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
Exception
- if something wrong happenspublic AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart content) throws Exception
AsyncCompletionHandler
onBodyPartReceived
in interface AsyncHandler<Response>
onBodyPartReceived
in class AsyncCompletionHandler<Response>
content
- response's body part.
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
Exception
- if something wrong happenspublic Response onCompleted(Response response) throws Exception
AsyncCompletionHandler
onCompleted
in class AsyncCompletionHandlerBase
response
- The Response
Future
Exception
- if something wrong happenspublic AsyncHandler.STATE onHeaderWriteCompleted()
File
, String
or FileInputStream
has been fully
written on the I/O socket.
onHeaderWriteCompleted
in interface ProgressAsyncHandler<Response>
onHeaderWriteCompleted
in class AsyncCompletionHandler<Response>
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.public AsyncHandler.STATE onContentWriteCompleted()
File
, String
or FileInputStream
has been fully
written on the I/O socket.
onContentWriteCompleted
in interface ProgressAsyncHandler<Response>
onContentWriteCompleted
in class AsyncCompletionHandler<Response>
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.public AsyncHandler.STATE onContentWriteProgress(long amount, long current, long total)
Request
body as been progressed.
onContentWriteProgress
in interface ProgressAsyncHandler<Response>
onContentWriteProgress
in class AsyncCompletionHandler<Response>
amount
- The amount of bytes to transfer.current
- The amount of bytes transferredtotal
- The total number of bytes transferred
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.public void onThrowable(Throwable t)
AsyncCompletionHandler
onThrowable
in interface AsyncHandler<Response>
onThrowable
in class AsyncCompletionHandlerBase
t
- a Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |