Package org.apache.http.nio.protocol
Interface HttpAsyncExchange
-
public interface HttpAsyncExchange
HttpAsyncExchange
represents 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 HttpRequest
getRequest()
Returns the received HTTP request message.HttpResponse
getResponse()
Returns the default HTTP response message.int
getTimeout()
Returns timeout for this message exchange.boolean
isCompleted()
Determines whether or not the message exchange has been completed.void
setCallback(Cancellable cancellable)
SetsCancellable
callback to be invoked in case the underlying connection times out or gets terminated prematurely by the client.void
setTimeout(int timeout)
Sets timeout for this message exchange.void
submitResponse()
Submits the default HTTP response and completed the message exchange.void
submitResponse(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 anHttpEntity
instance the entity is also expected to implement theHttpAsyncContentProducer
interface 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:
true
if the message exchange has been completed,false
otherwise.
-
setCallback
void setCallback(Cancellable cancellable)
SetsCancellable
callback 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.
-
-