public abstract class ZeroCopyConsumer<T> extends org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
HttpAsyncResponseConsumer
implementation that
streams content entity enclosed in an HTTP response directly into a file
without an intermediate in-memory buffer.
This consumer can be useful for file downloads.
Constructor and Description |
---|
ZeroCopyConsumer(File file) |
Modifier and Type | Method and Description |
---|---|
protected T |
buildResult(HttpContext context) |
protected void |
onContentReceived(org.apache.http.nio.ContentDecoder decoder,
org.apache.http.nio.IOControl ioctrl) |
protected void |
onEntityEnclosed(HttpEntity entity,
ContentType contentType) |
protected void |
onResponseReceived(HttpResponse response) |
protected abstract T |
process(HttpResponse response,
File file,
ContentType contentType)
Invoked to process received file.
|
protected void |
releaseResources() |
cancel, close, consumeContent, failed, getContentType, getException, getResult, isDone, onClose, responseCompleted, responseReceived
public ZeroCopyConsumer(File file) throws FileNotFoundException
FileNotFoundException
protected void onResponseReceived(HttpResponse response)
onResponseReceived
in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException
onEntityEnclosed
in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
IOException
protected void onContentReceived(org.apache.http.nio.ContentDecoder decoder, org.apache.http.nio.IOControl ioctrl) throws IOException
onContentReceived
in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
IOException
protected abstract T process(HttpResponse response, File file, ContentType contentType) throws Exception
response
- original response head.file
- file containing response content.contentType
- the cotnent type.Exception
protected T buildResult(HttpContext context) throws Exception
buildResult
in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
Exception
protected void releaseResources()
releaseResources
in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
Copyright © 2010–2021 The Apache Software Foundation. All rights reserved.