Package org.apache.http.nio.protocol
Class AbstractAsyncResponseConsumer<T>
java.lang.Object
org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,Cancellable,HttpAsyncResponseConsumer<T>
- Direct Known Subclasses:
BasicAsyncResponseConsumer
public abstract class AbstractAsyncResponseConsumer<T>
extends Object
implements HttpAsyncResponseConsumer<T>
Abstract
HttpAsyncResponseConsumer implementation that relieves its
subclasses from having to manage internal state and provides a number of protected
event methods that they need to implement.- Since:
- 4.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleancancel()final voidclose()final voidconsumeContent(ContentDecoder decoder, IOControl ioctrl) UseonContentReceived(ContentDecoder, IOControl)instead.final voidInvoked to signal that the response processing terminated abnormally.Returns an exception in case of an abnormal termination.Returns a result of the response processing, when available.booleanisDone()Determines whether or not the response processing completed.final voidresponseCompleted(HttpContext context) UsebuildResult(HttpContext)instead.final voidresponseReceived(HttpResponse response) UseonResponseReceived(HttpResponse)instead.
-
Constructor Details
-
AbstractAsyncResponseConsumer
public AbstractAsyncResponseConsumer()
-
-
Method Details
-
responseReceived
UseonResponseReceived(HttpResponse)instead.- Specified by:
responseReceivedin interfaceHttpAsyncResponseConsumer<T>- Parameters:
response- HTTP response message.- Throws:
IOException- in case of an I/O errorHttpException- in case of HTTP protocol violation
-
consumeContent
UseonContentReceived(ContentDecoder, IOControl)instead.- Specified by:
consumeContentin interfaceHttpAsyncResponseConsumer<T>- Parameters:
decoder- content decoder.ioctrl- I/O control of the underlying connection.- Throws:
IOException- in case of an I/O error
-
responseCompleted
UsebuildResult(HttpContext)instead.- Specified by:
responseCompletedin interfaceHttpAsyncResponseConsumer<T>- Parameters:
context- HTTP context
-
cancel
public final boolean cancel()- Specified by:
cancelin interfaceCancellable
-
failed
Description copied from interface:HttpAsyncResponseConsumerInvoked to signal that the response processing terminated abnormally.- Specified by:
failedin interfaceHttpAsyncResponseConsumer<T>- Parameters:
ex- exception
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getException
Description copied from interface:HttpAsyncResponseConsumerReturns an exception in case of an abnormal termination. This method returnsnullif the response processing is still ongoing or if it completed successfully.- Specified by:
getExceptionin interfaceHttpAsyncResponseConsumer<T>- See Also:
-
getResult
Description copied from interface:HttpAsyncResponseConsumerReturns a result of the response processing, when available. This method returnsnullif the response processing is still ongoing.- Specified by:
getResultin interfaceHttpAsyncResponseConsumer<T>- See Also:
-
isDone
public boolean isDone()Description copied from interface:HttpAsyncResponseConsumerDetermines whether or not the response processing completed. If the response processing terminated normallyHttpAsyncResponseConsumer.getResult()can be used to obtain the result. If the response processing terminated abnormallyHttpAsyncResponseConsumer.getException()can be used to obtain the cause.- Specified by:
isDonein interfaceHttpAsyncResponseConsumer<T>
-