Package org.apache.http.nio.protocol
Interface HttpAsyncResponseConsumer<T>
-
- Type Parameters:
T
- the result type of response processing.
- All Superinterfaces:
java.lang.AutoCloseable
,Cancellable
,java.io.Closeable
- All Known Subinterfaces:
HttpAsyncRequestExecutionHandler<T>
- All Known Implementing Classes:
AbstractAsyncResponseConsumer
,BasicAsyncRequestExecutionHandler
,BasicAsyncResponseConsumer
public interface HttpAsyncResponseConsumer<T> extends java.io.Closeable, Cancellable
HttpAsyncResponseConsumer
is a callback interface whose methods get invoked to process an HTTP response message and to stream message content from a non-blocking HTTP connection on the client side.- Since:
- 4.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
consumeContent(ContentDecoder decoder, IOControl ioctrl)
Invoked to process a chunk of content from theContentDecoder
.void
failed(java.lang.Exception ex)
Invoked to signal that the response processing terminated abnormally.java.lang.Exception
getException()
Returns an exception in case of an abnormal termination.T
getResult()
Returns a result of the response processing, when available.boolean
isDone()
Determines whether or not the response processing completed.void
responseCompleted(HttpContext context)
Invoked to signal that the response has been fully processed.void
responseReceived(HttpResponse response)
Invoked when a HTTP response message is received.-
Methods inherited from interface org.apache.http.concurrent.Cancellable
cancel
-
-
-
-
Method Detail
-
responseReceived
void responseReceived(HttpResponse response) throws java.io.IOException, HttpException
Invoked when a HTTP response message is received. Please note that theconsumeContent(ContentDecoder, IOControl)
method will be invoked only if the response messages has a content entity enclosed.- Parameters:
response
- HTTP response 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
. 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.- Parameters:
decoder
- content decoder.ioctrl
- I/O control of the underlying connection.- Throws:
java.io.IOException
- in case of an I/O error
-
responseCompleted
void responseCompleted(HttpContext context)
Invoked to signal that the response has been fully processed.- Parameters:
context
- HTTP context
-
failed
void failed(java.lang.Exception ex)
Invoked to signal that the response processing terminated abnormally.- Parameters:
ex
- exception
-
getException
java.lang.Exception getException()
Returns an exception in case of an abnormal termination. This method returnsnull
if the response processing is still ongoing or if it completed successfully.- See Also:
isDone()
-
getResult
T getResult()
Returns a result of the response processing, when available. This method returnsnull
if the response processing is still ongoing.- See Also:
isDone()
-
isDone
boolean isDone()
Determines whether or not the response processing completed. If the response processing terminated normallygetResult()
can be used to obtain the result. If the response processing terminated abnormallygetException()
can be used to obtain the cause.
-
-