public class BasicAsyncResponseConsumer extends AbstractAsyncResponseConsumer<HttpResponse>
HttpAsyncResponseConsumer
. Please note that
this consumer buffers response content in memory and should be used for
relatively small response messages.Modifier and Type | Field and Description |
---|---|
private SimpleInputBuffer |
buf |
private static int |
MAX_INITIAL_BUFFER_SIZE |
private HttpResponse |
response |
Constructor and Description |
---|
BasicAsyncResponseConsumer() |
Modifier and Type | Method and Description |
---|---|
protected HttpResponse |
buildResult(HttpContext context)
Invoked to generate a result object from the received HTTP response
message.
|
protected void |
onContentReceived(ContentDecoder decoder,
IOControl ioctrl)
Invoked to process a chunk of content from the
ContentDecoder . |
protected void |
onEntityEnclosed(HttpEntity entity,
ContentType contentType)
Invoked if the response message encloses a content entity.
|
protected void |
onResponseReceived(HttpResponse response)
Invoked when a HTTP response message is received.
|
protected void |
releaseResources()
Invoked to release all system resources currently allocated.
|
cancel, close, consumeContent, failed, getContentType, getException, getResult, isDone, onClose, responseCompleted, responseReceived
private static final int MAX_INITIAL_BUFFER_SIZE
private volatile HttpResponse response
private volatile SimpleInputBuffer buf
public BasicAsyncResponseConsumer()
protected void onResponseReceived(HttpResponse response) throws IOException
AbstractAsyncResponseConsumer
AbstractAsyncResponseConsumer.onContentReceived(ContentDecoder, IOControl)
method
will be invoked only if the response messages has a content entity
enclosed.onResponseReceived
in class AbstractAsyncResponseConsumer<HttpResponse>
response
- HTTP response message.IOException
- in case of an I/O errorprotected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException
AbstractAsyncResponseConsumer
onEntityEnclosed
in class AbstractAsyncResponseConsumer<HttpResponse>
entity
- HTTP entitycontentType
- expected content type.IOException
- in case of an I/O errorprotected void onContentReceived(ContentDecoder decoder, IOControl ioctrl) throws IOException
AbstractAsyncResponseConsumer
ContentDecoder
.
The IOControl
interface can be used to suspend input events
if the consumer is temporarily unable to consume more content.
The consumer can use the ContentDecoder.isCompleted()
method
to find out whether or not the message content has been fully consumed.
onContentReceived
in class AbstractAsyncResponseConsumer<HttpResponse>
decoder
- content decoder.ioctrl
- I/O control of the underlying connection.IOException
- in case of an I/O errorprotected void releaseResources()
AbstractAsyncResponseConsumer
releaseResources
in class AbstractAsyncResponseConsumer<HttpResponse>
protected HttpResponse buildResult(HttpContext context)
AbstractAsyncResponseConsumer
buildResult
in class AbstractAsyncResponseConsumer<HttpResponse>
context
- HTTP context.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses