Package org.apache.http.nio.protocol
Interface HttpAsyncExchange
-
public interface HttpAsyncExchangeHttpAsyncExchangerepresents a server-side HTTP message exchange where an HTTP response can be deferred without blocking the I/O event thread and triggered asynchronously at a later point of later time.- Since:
- 4.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HttpRequestgetRequest()Returns the received HTTP request message.HttpResponsegetResponse()Returns the default HTTP response message.intgetTimeout()Returns timeout for this message exchange.booleanisCompleted()Determines whether or not the message exchange has been completed.voidsetCallback(Cancellable cancellable)SetsCancellablecallback to be invoked in case the underlying connection times out or gets terminated prematurely by the client.voidsetTimeout(int timeout)Sets timeout for this message exchange.voidsubmitResponse()Submits the default HTTP response and completed the message exchange.voidsubmitResponse(HttpAsyncResponseProducer responseProducer)Submits an HTTP response using a customHttpAsyncResponseProducer.
-
-
-
Method Detail
-
getRequest
HttpRequest getRequest()
Returns the received HTTP request message.- Returns:
- received HTTP request message.
-
getResponse
HttpResponse getResponse()
Returns the default HTTP response message. Once ready the response message can submitted usingsubmitResponse()method.- Returns:
- default HTTP response message.
-
submitResponse
void submitResponse()
Submits the default HTTP response and completed the message exchange. If the response encloses anHttpEntityinstance the entity is also expected to implement theHttpAsyncContentProducerinterface for efficient content streaming to a non-blocking HTTP connection.- Throws:
java.lang.IllegalStateException- if a response has already been submitted.
-
submitResponse
void submitResponse(HttpAsyncResponseProducer responseProducer)
Submits an HTTP response using a customHttpAsyncResponseProducer.- Throws:
java.lang.IllegalStateException- if a response has already been submitted.
-
isCompleted
boolean isCompleted()
Determines whether or not the message exchange has been completed.- Returns:
trueif the message exchange has been completed,falseotherwise.
-
setCallback
void setCallback(Cancellable cancellable)
SetsCancellablecallback to be invoked in case the underlying connection times out or gets terminated prematurely by the client. This callback can be used to cancel a long running response generating process if a response is no longer needed.
-
setTimeout
void setTimeout(int timeout)
Sets timeout for this message exchange.
-
getTimeout
int getTimeout()
Returns timeout for this message exchange.
-
-