public abstract class

AsyncCompletionHandler

extends Object
implements AsyncHandler<T> ProgressAsyncHandler<T>
java.lang.Object
   ↳ com.ning.http.client.AsyncCompletionHandler<T>
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

An AsyncHandler augmented with an onCompleted(Response) convenience method which gets called when the Response processing is finished. This class also implement the ProgressAsyncHandler callback, all doing nothing except returning CONTINUE

Summary

Public Constructors
AsyncCompletionHandler()
Public Methods
AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart content)
Invoked as soon as some response body part are received.
final T onCompleted()
Invoked once the HTTP response processing is finished.
abstract T onCompleted(Response response)
Invoked once the HTTP response processing is finished.
AsyncHandler.STATE onContentWriteCompleted()
Invoked when the content (a java.io.File, String or java.io.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 onHeaderWriteCompleted()
Invoked when the content (a java.io.File, String or java.io.FileInputStream has been fully written on the I/O socket.
AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers)
Invoked as soon as the HTTP headers has been received.
AsyncHandler.STATE onStatusReceived(HttpResponseStatus status)
Invoked as soon as the HTTP status line has been received
void onThrowable(Throwable t)
Invoked when an unexpected exception occurs during the processing of the response.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.ning.http.client.AsyncHandler
From interface com.ning.http.client.ProgressAsyncHandler

Public Constructors

public AsyncCompletionHandler ()

Public Methods

public AsyncHandler.STATE onBodyPartReceived (HttpResponseBodyPart content)

Invoked as soon as some response body part are received. Could be invoked many times.

Parameters
content response's body part.
Returns
Throws
Exception

public final 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

public abstract T onCompleted (Response response)

Invoked once the HTTP response processing is finished.

Gets always invoked as last callback method.

Parameters
response The Response
Returns
  • T Value that will be returned by the associated java.util.concurrent.Future
Throws
Exception if something wrong happens

public AsyncHandler.STATE onContentWriteCompleted ()

Invoked when the content (a java.io.File, String or java.io.FileInputStream has been fully written on the I/O socket.

Returns

public AsyncHandler.STATE onContentWriteProgress (long amount, long current, long total)

Invoked when the I/O operation associated with the Request body as been progressed.

Parameters
amount The amount of bytes to transfer.
current The amount of bytes transferred
total The total number of bytes transferred
Returns

public AsyncHandler.STATE onHeaderWriteCompleted ()

Invoked when the content (a java.io.File, String or java.io.FileInputStream has been fully written on the I/O socket.

Returns

public AsyncHandler.STATE onHeadersReceived (HttpResponseHeaders headers)

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.
Returns
Throws
Exception

public AsyncHandler.STATE onStatusReceived (HttpResponseStatus status)

Invoked as soon as the HTTP status line has been received

Parameters
status the status code and test of the response
Returns
Throws
Exception

public 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.

Parameters
t a Throwable