Package org.apache.http.nio.protocol
Class BasicAsyncResponseConsumer
java.lang.Object
org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<HttpResponse>
org.apache.http.nio.protocol.BasicAsyncResponseConsumer
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Cancellable
,HttpAsyncResponseConsumer<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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SimpleInputBuffer
private static final int
private HttpResponse
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpResponse
buildResult
(HttpContext context) Invoked to generate a result object from the received HTTP response message.protected void
onContentReceived
(ContentDecoder decoder, IOControl ioControl) Invoked to process a chunk of content from theContentDecoder
.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
Invoked 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
-
Field Details
-
MAX_INITIAL_BUFFER_SIZE
private static final int MAX_INITIAL_BUFFER_SIZE- See Also:
-
response
-
buf
-
-
Constructor Details
-
BasicAsyncResponseConsumer
public BasicAsyncResponseConsumer()
-
-
Method Details
-
onResponseReceived
Description copied from class:AbstractAsyncResponseConsumer
Invoked 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:
onResponseReceived
in classAbstractAsyncResponseConsumer<HttpResponse>
- Parameters:
response
- HTTP response message.- Throws:
IOException
- in case of an I/O error
-
onEntityEnclosed
Description copied from class:AbstractAsyncResponseConsumer
Invoked if the response message encloses a content entity.- Specified by:
onEntityEnclosed
in classAbstractAsyncResponseConsumer<HttpResponse>
- Parameters:
entity
- HTTP entitycontentType
- expected content type.- Throws:
IOException
- in case of an I/O error
-
onContentReceived
Description copied from class:AbstractAsyncResponseConsumer
Invoked to process a chunk of content from theContentDecoder
. TheIOControl
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.- Specified by:
onContentReceived
in classAbstractAsyncResponseConsumer<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:AbstractAsyncResponseConsumer
Invoked to release all system resources currently allocated.- Specified by:
releaseResources
in classAbstractAsyncResponseConsumer<HttpResponse>
-
buildResult
Description copied from class:AbstractAsyncResponseConsumer
Invoked to generate a result object from the received HTTP response message.- Specified by:
buildResult
in classAbstractAsyncResponseConsumer<HttpResponse>
- Parameters:
context
- HTTP context.- Returns:
- result of the response processing.
-