public class

ResumableAsyncHandler

extends Object
implements AsyncHandler<T>
java.lang.Object
   ↳ com.ning.http.client.resumable.ResumableAsyncHandler<T>

Class Overview

An AsyncHandler which support resumable download, e.g when used with an ResumableIOExceptionFilter, this handler can resume the download operation at the point it was before the interruption occured. This prevent having to download the entire file again. It's the responsibility of the TransferListener to track how many bytes has been transferred and to properly adjust the file's write position.

In case of a JVM crash/shutdown, you can create an instance of this class and pass the last valid bytes position.

Summary

Nested Classes
interface ResumableAsyncHandler.ResumableProcessor An interface to implement in order to manage the way the incomplete file management are handled. 
Public Constructors
ResumableAsyncHandler()
ResumableAsyncHandler(boolean accumulateBody)
ResumableAsyncHandler(AsyncHandler<T> decoratedAsyncHandler)
ResumableAsyncHandler(ResumableAsyncHandler.ResumableProcessor resumableProcessor)
ResumableAsyncHandler(ResumableAsyncHandler.ResumableProcessor resumableProcessor, boolean accumulateBody)
ResumableAsyncHandler(long byteTransferred)
ResumableAsyncHandler(long byteTransferred, AsyncHandler<T> decoratedAsyncHandler)
Public Methods
Request adjustRequestRange(Request request)
Invoke this API if you want to set the Range header on your Request based on the last valid bytes position.
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 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.
ResumableAsyncHandler setResumableListener(ResumableListener resumableListener)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.ning.http.client.AsyncHandler

Public Constructors

public ResumableAsyncHandler ()

public ResumableAsyncHandler (boolean accumulateBody)

public ResumableAsyncHandler (AsyncHandler<T> decoratedAsyncHandler)

public ResumableAsyncHandler (ResumableAsyncHandler.ResumableProcessor resumableProcessor)

public ResumableAsyncHandler (ResumableAsyncHandler.ResumableProcessor resumableProcessor, boolean accumulateBody)

public ResumableAsyncHandler (long byteTransferred)

public ResumableAsyncHandler (long byteTransferred, AsyncHandler<T> decoratedAsyncHandler)

Public Methods

public Request adjustRequestRange (Request request)

Invoke this API if you want to set the Range header on your Request based on the last valid bytes position.

Parameters
request Request
Returns
  • a Request with the Range header properly set.

public AsyncHandler.STATE onBodyPartReceived (HttpResponseBodyPart bodyPart)

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

Parameters
bodyPart response's body part.
Returns
Throws
Exception

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

public ResumableAsyncHandler setResumableListener (ResumableListener resumableListener)

Parameters
resumableListener a ResumableListener
Returns
  • this