org.apache.http.nio.protocol
Class BasicAsyncRequestConsumer

java.lang.Object
  extended by org.apache.http.nio.protocol.AbstractAsyncRequestConsumer<HttpRequest>
      extended by org.apache.http.nio.protocol.BasicAsyncRequestConsumer
All Implemented Interfaces:
Closeable, HttpAsyncRequestConsumer<HttpRequest>

public class BasicAsyncRequestConsumer
extends AbstractAsyncRequestConsumer<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

Constructor Summary
BasicAsyncRequestConsumer()
           
 
Method Summary
protected  HttpRequest buildResult(HttpContext context)
          Invoked to generate a result object from the received HTTP request message.
protected  void onContentReceived(ContentDecoder decoder, IOControl ioControl)
          Invoked to process a chunk of content from the ContentDecoder.
protected  void onEntityEnclosed(HttpEntity entity, ContentType contentType)
          Invoked if the request message encloses a content entity.
protected  void onRequestReceived(HttpRequest request)
          Invoked when a HTTP request message is received.
protected  void releaseResources()
          Invoked 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicAsyncRequestConsumer

public BasicAsyncRequestConsumer()
Method Detail

onRequestReceived

protected void onRequestReceived(HttpRequest request)
                          throws IOException
Description copied from class: AbstractAsyncRequestConsumer
Invoked when a HTTP request message is received. Please note that the AbstractAsyncRequestConsumer.onContentReceived(ContentDecoder, IOControl) method will be invoked only for if the request message implements HttpEntityEnclosingRequest interface and has a content entity enclosed.

Specified by:
onRequestReceived in class AbstractAsyncRequestConsumer<HttpRequest>
Parameters:
request - HTTP request message.
Throws:
IOException - in case of an I/O error

onEntityEnclosed

protected void onEntityEnclosed(HttpEntity entity,
                                ContentType contentType)
                         throws IOException
Description copied from class: AbstractAsyncRequestConsumer
Invoked if the request message encloses a content entity.

Specified by:
onEntityEnclosed in class AbstractAsyncRequestConsumer<HttpRequest>
Parameters:
entity - HTTP entity
contentType - expected content type.
Throws:
IOException - in case of an I/O error

onContentReceived

protected void onContentReceived(ContentDecoder decoder,
                                 IOControl ioControl)
                          throws IOException
Description copied from class: AbstractAsyncRequestConsumer
Invoked to process a chunk of content from the 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.

Specified by:
onContentReceived in class AbstractAsyncRequestConsumer<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: AbstractAsyncRequestConsumer
Invoked to release all system resources currently allocated.

Specified by:
releaseResources in class AbstractAsyncRequestConsumer<HttpRequest>

buildResult

protected HttpRequest buildResult(HttpContext context)
Description copied from class: AbstractAsyncRequestConsumer
Invoked to generate a result object from the received HTTP request message.

Specified by:
buildResult in class AbstractAsyncRequestConsumer<HttpRequest>
Parameters:
context - HTTP context.
Returns:
result of the request processing.


Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.