Package org.apache.http.nio.protocol
Class BasicAsyncRequestConsumer
java.lang.Object
org.apache.http.nio.protocol.AbstractAsyncRequestConsumer<HttpRequest>
org.apache.http.nio.protocol.BasicAsyncRequestConsumer
- All Implemented Interfaces:
Closeable,AutoCloseable,HttpAsyncRequestConsumer<HttpRequest>
Basic implementation of
HttpAsyncRequestConsumer. Please note that
this consumer buffers request content in memory and should be used for
relatively small request messages.- Since:
- 4.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SimpleInputBufferprivate static final intprivate HttpRequest -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpRequestbuildResult(HttpContext context) Invoked to generate a result object from the received HTTP request message.protected voidonContentReceived(ContentDecoder decoder, IOControl ioControl) Invoked to process a chunk of content from theContentDecoder.protected voidonEntityEnclosed(HttpEntity entity, ContentType contentType) Invoked if the request message encloses a content entity.protected voidonRequestReceived(HttpRequest request) Invoked when a HTTP request message is received.protected voidInvoked to release all system resources currently allocated.Methods inherited from class org.apache.http.nio.protocol.AbstractAsyncRequestConsumer
close, consumeContent, failed, getException, getResult, isDone, onClose, requestCompleted, requestReceived
-
Field Details
-
MAX_INITIAL_BUFFER_SIZE
private static final int MAX_INITIAL_BUFFER_SIZE- See Also:
-
request
-
buf
-
-
Constructor Details
-
BasicAsyncRequestConsumer
public BasicAsyncRequestConsumer()
-
-
Method Details
-
onRequestReceived
Description copied from class:AbstractAsyncRequestConsumerInvoked when a HTTP request message is received. Please note that theAbstractAsyncRequestConsumer.onContentReceived(ContentDecoder, IOControl)method will be invoked only for if the request message implementsHttpEntityEnclosingRequestinterface and has a content entity enclosed.- Specified by:
onRequestReceivedin classAbstractAsyncRequestConsumer<HttpRequest>- Parameters:
request- HTTP request message.- Throws:
IOException- in case of an I/O error
-
onEntityEnclosed
Description copied from class:AbstractAsyncRequestConsumerInvoked if the request message encloses a content entity.- Specified by:
onEntityEnclosedin classAbstractAsyncRequestConsumer<HttpRequest>- Parameters:
entity- HTTP entitycontentType- expected content type.- Throws:
IOException- in case of an I/O error
-
onContentReceived
Description copied from class:AbstractAsyncRequestConsumerInvoked 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 classAbstractAsyncRequestConsumer<HttpRequest>- 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:AbstractAsyncRequestConsumerInvoked to release all system resources currently allocated.- Specified by:
releaseResourcesin classAbstractAsyncRequestConsumer<HttpRequest>
-
buildResult
Description copied from class:AbstractAsyncRequestConsumerInvoked to generate a result object from the received HTTP request message.- Specified by:
buildResultin classAbstractAsyncRequestConsumer<HttpRequest>- Parameters:
context- HTTP context.- Returns:
- result of the request processing.
-