Package org.apache.http.nio.protocol
Interface HttpAsyncRequestConsumer<T>
-
- Type Parameters:
T- the result type of request processing.
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- All Known Implementing Classes:
AbstractAsyncRequestConsumer,BasicAsyncRequestConsumer
public interface HttpAsyncRequestConsumer<T> extends java.io.CloseableHttpAsyncRequestConsumeris a callback interface whose methods get invoked to process an HTTP request message and to stream message content from a non-blocking HTTP connection on the server side.- Since:
- 4.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidconsumeContent(ContentDecoder decoder, IOControl ioctrl)Invoked to process a chunk of content from theContentDecoder.voidfailed(java.lang.Exception ex)Invoked to signal that the request processing terminated abnormally.java.lang.ExceptiongetException()Returns an exception in case of an abnormal termination.TgetResult()Returns a result of the request execution, when available.booleanisDone()Determines whether or not the request execution completed.voidrequestCompleted(HttpContext context)Invoked to signal that the request has been fully processed.voidrequestReceived(HttpRequest request)Invoked when a HTTP request message is received.
-
-
-
Method Detail
-
requestReceived
void requestReceived(HttpRequest request) throws HttpException, java.io.IOException
Invoked when a HTTP request message is received. Please note that theconsumeContent(ContentDecoder, IOControl)method will be invoked only for if the request message implementsHttpEntityEnclosingRequestinterface and has a content entity enclosed.- Parameters:
request- HTTP request message.- Throws:
HttpException- in case of HTTP protocol violationjava.io.IOException- in case of an I/O error
-
consumeContent
void consumeContent(ContentDecoder decoder, IOControl ioctrl) throws java.io.IOException
Invoked to process a chunk of content from theContentDecoder. TheIOControlinterface 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
ContentDecoderobject is not thread-safe and should only be used within the context of this method call. TheIOControlobject can be shared and used on other thread to resume input event notifications when the consumer is capable of processing more content.- Parameters:
decoder- content decoder.ioctrl- I/O control of the underlying connection.- Throws:
java.io.IOException- in case of an I/O error
-
requestCompleted
void requestCompleted(HttpContext context)
Invoked to signal that the request has been fully processed.- Parameters:
context- HTTP context
-
failed
void failed(java.lang.Exception ex)
Invoked to signal that the request processing terminated abnormally.- Parameters:
ex- exception
-
getException
java.lang.Exception getException()
Returns an exception in case of an abnormal termination. This method returnsnullif the request execution is still ongoing or if it completed successfully.- See Also:
isDone()
-
getResult
T getResult()
Returns a result of the request execution, when available. This method returnsnullif the request execution is still ongoing.- See Also:
isDone()
-
isDone
boolean isDone()
Determines whether or not the request execution completed. If the request processing terminated normallygetResult()can be used to obtain the result. If the request processing terminated abnormallygetException()can be used to obtain the cause.
-
-