public class ResumableAsyncHandler extends Object implements AsyncHandler<Response>
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 occurred. This prevent having to
download the entire file again. It's the responsibility of the ResumableAsyncHandler
to track how many bytes has been transferred and to properly adjust the file's write position.
Modifier and Type | Class and Description |
---|---|
static interface |
ResumableAsyncHandler.ResumableProcessor
An interface to implement in order to manage the way the incomplete file management are handled.
|
AsyncHandler.State
Constructor and Description |
---|
ResumableAsyncHandler() |
ResumableAsyncHandler(AsyncHandler<Response> decoratedAsyncHandler) |
ResumableAsyncHandler(boolean accumulateBody) |
ResumableAsyncHandler(long byteTransferred) |
ResumableAsyncHandler(long byteTransferred,
AsyncHandler<Response> decoratedAsyncHandler) |
ResumableAsyncHandler(ResumableAsyncHandler.ResumableProcessor resumableProcessor) |
ResumableAsyncHandler(ResumableAsyncHandler.ResumableProcessor resumableProcessor,
boolean accumulateBody) |
Modifier and Type | Method and Description |
---|---|
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.
|
Response |
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)
Set a
ResumableListener |
public ResumableAsyncHandler(long byteTransferred)
public ResumableAsyncHandler(boolean accumulateBody)
public ResumableAsyncHandler()
public ResumableAsyncHandler(AsyncHandler<Response> decoratedAsyncHandler)
public ResumableAsyncHandler(long byteTransferred, AsyncHandler<Response> decoratedAsyncHandler)
public ResumableAsyncHandler(ResumableAsyncHandler.ResumableProcessor resumableProcessor)
public ResumableAsyncHandler(ResumableAsyncHandler.ResumableProcessor resumableProcessor, boolean accumulateBody)
public AsyncHandler.State onStatusReceived(HttpResponseStatus status) throws Exception
onStatusReceived
in interface AsyncHandler<Response>
status
- the status code and test of the responseAsyncHandler.State
telling to CONTINUE or ABORT the current processing.Exception
- if something wrong happenspublic void onThrowable(Throwable t)
onThrowable
in interface AsyncHandler<Response>
t
- a Throwable
public AsyncHandler.State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception
onBodyPartReceived
in interface AsyncHandler<Response>
bodyPart
- response's body part.AsyncHandler.State
telling to CONTINUE or ABORT the current processing. Aborting will also close the connection.Exception
- if something wrong happenspublic Response onCompleted() throws Exception
onCompleted
in interface AsyncHandler<Response>
Future
Exception
- if something wrong happenspublic AsyncHandler.State onHeadersReceived(HttpResponseHeaders headers) throws Exception
onHeadersReceived
in interface AsyncHandler<Response>
headers
- the HTTP headers.AsyncHandler.State
telling to CONTINUE or ABORT the current processing.Exception
- if something wrong happenspublic Request adjustRequestRange(Request request)
Request
based on the last valid bytes
position.public ResumableAsyncHandler setResumableListener(ResumableListener resumableListener)
ResumableListener
resumableListener
- a ResumableListener
Copyright © 2015. All Rights Reserved.