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(org.apache.http.protocol.HttpContext context) |
protected void |
onContentReceived(org.apache.http.nio.ContentDecoder decoder,
org.apache.http.nio.IOControl ioctrl) |
protected void |
onEntityEnclosed(org.apache.http.HttpEntity entity,
org.apache.http.entity.ContentType contentType) |
protected void |
onResponseReceived(org.apache.http.HttpResponse response) |
protected abstract T |
process(org.apache.http.HttpResponse response,
File file,
org.apache.http.entity.ContentType contentType)
Invoked to process received file.
|
protected void |
releaseResources() |
public ZeroCopyConsumer(File file) throws FileNotFoundException
FileNotFoundExceptionprotected void onResponseReceived(org.apache.http.HttpResponse response)
onResponseReceived in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>protected void onEntityEnclosed(org.apache.http.HttpEntity entity,
org.apache.http.entity.ContentType contentType)
throws IOException
onEntityEnclosed in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>IOExceptionprotected 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>IOExceptionprotected abstract T process(org.apache.http.HttpResponse response, File file, org.apache.http.entity.ContentType contentType) throws Exception
response - original response head.file - file containing response content.contentType - the cotnent type.Exceptionprotected void releaseResources()
releaseResources in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>Copyright © 2010–2016 The Apache Software Foundation. All rights reserved.