Interface HttpAsyncClientExchangeHandler
-
- All Superinterfaces:
java.lang.AutoCloseable,Cancellable,java.io.Closeable
- All Known Implementing Classes:
BasicAsyncClientExchangeHandler,PipeliningClientExchangeHandler
public interface HttpAsyncClientExchangeHandler extends java.io.Closeable, Cancellable
HttpAsyncClientExchangeHandlerrepresents a callback interface whose methods get invoked when executing one or multiple HTTP message exchanges on the client side.Individual
HttpAsyncClientExchangeHandlerare expected to make use of aHttpProcessorto generate mandatory protocol headers for all outgoing messages and apply common, cross-cutting message transformations to all incoming and outgoing messages.HttpAsyncClientExchangeHandlers can delegate implementation of application specific content generation and processing to aHttpAsyncRequestProducerand aHttpAsyncResponseConsumer.- Since:
- 4.3
-
-
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 response processing terminated abnormally.HttpRequestgenerateRequest()Invoked to generate a HTTP request message head.voidinputTerminated()Invoked to signal that the connection has been terminated prematurely by the opposite end.booleanisDone()Determines whether or not the response processing completed.voidproduceContent(ContentEncoder encoder, IOControl ioctrl)Invoked to write out a chunk of content to theContentEncoder.voidrequestCompleted()Invoked to signal that the request has been fully written out.voidresponseCompleted()Invoked to signal that the response has been fully processed.voidresponseReceived(HttpResponse response)Invoked when a HTTP response message is received.-
Methods inherited from interface org.apache.http.concurrent.Cancellable
cancel
-
-
-
-
Method Detail
-
generateRequest
HttpRequest generateRequest() throws java.io.IOException, HttpException
Invoked to generate a HTTP request message head. The message is expected to implement theHttpEntityEnclosingRequestinterface if it is to enclose a content entity. TheproduceContent(ContentEncoder, IOControl)method will not be invoked ifHttpEntityEnclosingRequest.getEntity()returnsnull.- Returns:
- HTTP request message.
- Throws:
HttpException- in case of HTTP protocol violationjava.io.IOException- in case of an I/O error
-
produceContent
void produceContent(ContentEncoder encoder, IOControl ioctrl) throws java.io.IOException
Invoked to write out a chunk of content to theContentEncoder. TheIOControlinterface can be used to suspend output event notifications if the producer is temporarily unable to produce more content.When all content is finished, the producer MUST call
ContentEncoder.complete(). Failure to do so may cause the entity to be incorrectly delimited.Please note that the
ContentEncoderobject 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 output event notifications when more content is made available.- Parameters:
encoder- content encoder.ioctrl- I/O control of the underlying connection.- Throws:
java.io.IOException- in case of an I/O error
-
requestCompleted
void requestCompleted()
Invoked to signal that the request has been fully written out.
-
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. 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
-
responseCompleted
void responseCompleted() throws java.io.IOException, HttpExceptionInvoked to signal that the response has been fully processed.- Throws:
java.io.IOExceptionHttpException
-
inputTerminated
void inputTerminated()
Invoked to signal that the connection has been terminated prematurely by the opposite end.
-
failed
void failed(java.lang.Exception ex)
Invoked to signal that the response processing terminated abnormally.- Parameters:
ex- exception
-
isDone
boolean isDone()
Determines whether or not the response processing completed.
-
-