Package org.apache.http.nio.protocol
Class NullRequestConsumer
- java.lang.Object
-
- org.apache.http.nio.protocol.NullRequestConsumer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,HttpAsyncRequestConsumer<java.lang.Object>
class NullRequestConsumer extends java.lang.Object implements HttpAsyncRequestConsumer<java.lang.Object>
-
-
Constructor Summary
Constructors Constructor Description NullRequestConsumer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
consumeContent(ContentDecoder decoder, IOControl ioControl)
Invoked to process a chunk of content from theContentDecoder
.void
failed(java.lang.Exception ex)
Invoked to signal that the request processing terminated abnormally.java.lang.Exception
getException()
Returns an exception in case of an abnormal termination.java.lang.Object
getResult()
Returns a result of the request execution, when available.boolean
isDone()
Determines whether or not the request execution completed.void
requestCompleted(HttpContext context)
Invoked to signal that the request has been fully processed.void
requestReceived(HttpRequest request)
Invoked when a HTTP request message is received.
-
-
-
Method Detail
-
requestReceived
public void requestReceived(HttpRequest request)
Description copied from interface:HttpAsyncRequestConsumer
Invoked when a HTTP request message is received. Please note that theHttpAsyncRequestConsumer.consumeContent(ContentDecoder, IOControl)
method will be invoked only for if the request message implementsHttpEntityEnclosingRequest
interface and has a content entity enclosed.- Specified by:
requestReceived
in interfaceHttpAsyncRequestConsumer<java.lang.Object>
- Parameters:
request
- HTTP request message.
-
consumeContent
public void consumeContent(ContentDecoder decoder, IOControl ioControl) throws java.io.IOException
Description copied from interface:HttpAsyncRequestConsumer
Invoked to process a chunk of content from theContentDecoder
. TheIOControl
interface can be used to suspend input event notifications if the consumer is temporarily unable to process content.The consumer can use the
ContentDecoder.isCompleted()
method to find out whether or not the message content has been fully consumed.Please note that the
ContentDecoder
object is not thread-safe and should only be used within the context of this method call. TheIOControl
object can be shared and used on other thread to resume input event notifications when the consumer is capable of processing more content.- Specified by:
consumeContent
in interfaceHttpAsyncRequestConsumer<java.lang.Object>
- Parameters:
decoder
- content decoder.ioControl
- I/O control of the underlying connection.- Throws:
java.io.IOException
- in case of an I/O error
-
requestCompleted
public void requestCompleted(HttpContext context)
Description copied from interface:HttpAsyncRequestConsumer
Invoked to signal that the request has been fully processed.- Specified by:
requestCompleted
in interfaceHttpAsyncRequestConsumer<java.lang.Object>
- Parameters:
context
- HTTP context
-
failed
public void failed(java.lang.Exception ex)
Description copied from interface:HttpAsyncRequestConsumer
Invoked to signal that the request processing terminated abnormally.- Specified by:
failed
in interfaceHttpAsyncRequestConsumer<java.lang.Object>
- Parameters:
ex
- exception
-
getResult
public java.lang.Object getResult()
Description copied from interface:HttpAsyncRequestConsumer
Returns a result of the request execution, when available. This method returnsnull
if the request execution is still ongoing.- Specified by:
getResult
in interfaceHttpAsyncRequestConsumer<java.lang.Object>
- See Also:
HttpAsyncRequestConsumer.isDone()
-
getException
public java.lang.Exception getException()
Description copied from interface:HttpAsyncRequestConsumer
Returns an exception in case of an abnormal termination. This method returnsnull
if the request execution is still ongoing or if it completed successfully.- Specified by:
getException
in interfaceHttpAsyncRequestConsumer<java.lang.Object>
- See Also:
HttpAsyncRequestConsumer.isDone()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
isDone
public boolean isDone()
Description copied from interface:HttpAsyncRequestConsumer
Determines whether or not the request execution completed. If the request processing terminated normallyHttpAsyncRequestConsumer.getResult()
can be used to obtain the result. If the request processing terminated abnormallyHttpAsyncRequestConsumer.getException()
can be used to obtain the cause.- Specified by:
isDone
in interfaceHttpAsyncRequestConsumer<java.lang.Object>
-
-