Package org.apache.http.nio.protocol
Class BasicAsyncResponseConsumer
java.lang.Object
org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>
org.apache.http.nio.protocol.BasicAsyncResponseConsumer
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.http.concurrent.Cancellable,HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
public class BasicAsyncResponseConsumer
extends AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>
Basic implementation of
HttpAsyncResponseConsumer. Please note that
this consumer buffers response content in memory and should be used for
relatively small response messages.- Since:
- 4.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.http.HttpResponsebuildResult(org.apache.http.protocol.HttpContext context) Invoked to generate a result object from the received HTTP response message.protected voidonContentReceived(ContentDecoder decoder, IOControl ioControl) Invoked to process a chunk of content from theContentDecoder.protected voidonEntityEnclosed(org.apache.http.HttpEntity entity, org.apache.http.entity.ContentType contentType) Invoked if the response message encloses a content entity.protected voidonResponseReceived(org.apache.http.HttpResponse response) Invoked when a HTTP response message is received.protected voidInvoked to release all system resources currently allocated.Methods inherited from class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer
cancel, close, consumeContent, failed, getContentType, getException, getResult, isDone, onClose, responseCompleted, responseReceived
-
Constructor Details
-
BasicAsyncResponseConsumer
public BasicAsyncResponseConsumer()
-
-
Method Details
-
onResponseReceived
Description copied from class:AbstractAsyncResponseConsumerInvoked when a HTTP response message is received. Please note that theAbstractAsyncResponseConsumer.onContentReceived(ContentDecoder, IOControl)method will be invoked only if the response messages has a content entity enclosed.- Specified by:
onResponseReceivedin classAbstractAsyncResponseConsumer<org.apache.http.HttpResponse>- Parameters:
response- HTTP response message.- Throws:
IOException- in case of an I/O error
-
onEntityEnclosed
protected void onEntityEnclosed(org.apache.http.HttpEntity entity, org.apache.http.entity.ContentType contentType) throws IOException Description copied from class:AbstractAsyncResponseConsumerInvoked if the response message encloses a content entity.- Specified by:
onEntityEnclosedin classAbstractAsyncResponseConsumer<org.apache.http.HttpResponse>- Parameters:
entity- HTTP entitycontentType- expected content type.- Throws:
IOException- in case of an I/O error
-
onContentReceived
Description copied from class:AbstractAsyncResponseConsumerInvoked to process a chunk of content from theContentDecoder. TheIOControlinterface 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.- Specified by:
onContentReceivedin classAbstractAsyncResponseConsumer<org.apache.http.HttpResponse>- Parameters:
decoder- content decoder.ioControl- I/O control of the underlying connection.- Throws:
IOException- in case of an I/O error
-
releaseResources
protected void releaseResources()Description copied from class:AbstractAsyncResponseConsumerInvoked to release all system resources currently allocated.- Specified by:
releaseResourcesin classAbstractAsyncResponseConsumer<org.apache.http.HttpResponse>
-
buildResult
protected org.apache.http.HttpResponse buildResult(org.apache.http.protocol.HttpContext context) Description copied from class:AbstractAsyncResponseConsumerInvoked to generate a result object from the received HTTP response message.- Specified by:
buildResultin classAbstractAsyncResponseConsumer<org.apache.http.HttpResponse>- Parameters:
context- HTTP context.- Returns:
- result of the response processing.
-