public class HeapBufferedAsyncResponseConsumer
extends org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>
HttpAsyncResponseConsumer. Buffers the whole
response content in heap memory, meaning that the size of the buffer is equal to the content-length of the response.
Limits the size of responses that can be read to DEFAULT_BUFFER_LIMIT by default, configurable value.
Throws an exception in case the entity is longer than the configured buffer limit.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_LIMIT |
| Constructor and Description |
|---|
HeapBufferedAsyncResponseConsumer()
Creates a new instance of this consumer with a buffer limit of
DEFAULT_BUFFER_LIMIT |
HeapBufferedAsyncResponseConsumer(int bufferLimit)
Creates a new instance of this consumer with the provided buffer limit
|
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.http.HttpResponse |
buildResult(org.apache.http.protocol.HttpContext context) |
protected org.apache.http.nio.util.ByteBufferAllocator |
getByteBufferAllocator()
Returns the instance of
ByteBufferAllocator to use for content buffering. |
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 void |
releaseResources() |
public static final int DEFAULT_BUFFER_LIMIT
public HeapBufferedAsyncResponseConsumer()
DEFAULT_BUFFER_LIMITpublic HeapBufferedAsyncResponseConsumer(int bufferLimit)
protected void onResponseReceived(org.apache.http.HttpResponse response)
throws org.apache.http.HttpException,
java.io.IOException
onResponseReceived in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>org.apache.http.HttpExceptionjava.io.IOExceptionprotected void onEntityEnclosed(org.apache.http.HttpEntity entity,
org.apache.http.entity.ContentType contentType)
throws java.io.IOException
onEntityEnclosed in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>java.io.IOExceptionprotected org.apache.http.nio.util.ByteBufferAllocator getByteBufferAllocator()
ByteBufferAllocator to use for content buffering.
Allows to plug in any ByteBufferAllocator implementation.protected void onContentReceived(org.apache.http.nio.ContentDecoder decoder,
org.apache.http.nio.IOControl ioctrl)
throws java.io.IOException
onContentReceived in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>java.io.IOExceptionprotected org.apache.http.HttpResponse buildResult(org.apache.http.protocol.HttpContext context)
throws java.lang.Exception
buildResult in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>java.lang.Exceptionprotected void releaseResources()
releaseResources in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>