Package org.apache.http.nio.protocol
Class HttpAsyncService.HttpAsyncExchangeImpl
- java.lang.Object
-
- org.apache.http.nio.protocol.HttpAsyncService.HttpAsyncExchangeImpl
-
- All Implemented Interfaces:
HttpAsyncExchange
- Enclosing class:
- HttpAsyncService
class HttpAsyncService.HttpAsyncExchangeImpl extends java.lang.Object implements HttpAsyncExchange
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBoolean
completed
private NHttpServerConnection
conn
private HttpContext
context
private HttpRequest
request
private HttpResponse
response
private HttpAsyncService.State
state
-
Constructor Summary
Constructors Constructor Description HttpAsyncExchangeImpl(HttpRequest request, HttpResponse response, HttpAsyncService.State state, NHttpServerConnection conn, HttpContext context)
-
Method Summary
All Methods Instance Methods Concrete 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
.
-
-
-
Field Detail
-
completed
private final java.util.concurrent.atomic.AtomicBoolean completed
-
request
private final HttpRequest request
-
response
private final HttpResponse response
-
state
private final HttpAsyncService.State state
-
conn
private final NHttpServerConnection conn
-
context
private final HttpContext context
-
-
Constructor Detail
-
HttpAsyncExchangeImpl
public HttpAsyncExchangeImpl(HttpRequest request, HttpResponse response, HttpAsyncService.State state, NHttpServerConnection conn, HttpContext context)
-
-
Method Detail
-
getRequest
public HttpRequest getRequest()
Description copied from interface:HttpAsyncExchange
Returns the received HTTP request message.- Specified by:
getRequest
in interfaceHttpAsyncExchange
- Returns:
- received HTTP request message.
-
getResponse
public HttpResponse getResponse()
Description copied from interface:HttpAsyncExchange
Returns the default HTTP response message. Once ready the response message can submitted usingHttpAsyncExchange.submitResponse()
method.- Specified by:
getResponse
in interfaceHttpAsyncExchange
- Returns:
- default HTTP response message.
-
setCallback
public void setCallback(Cancellable cancellable)
Description copied from interface:HttpAsyncExchange
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.- Specified by:
setCallback
in interfaceHttpAsyncExchange
-
submitResponse
public void submitResponse(HttpAsyncResponseProducer responseProducer)
Description copied from interface:HttpAsyncExchange
Submits an HTTP response using a customHttpAsyncResponseProducer
.- Specified by:
submitResponse
in interfaceHttpAsyncExchange
-
submitResponse
public void submitResponse()
Description copied from interface:HttpAsyncExchange
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.- Specified by:
submitResponse
in interfaceHttpAsyncExchange
-
isCompleted
public boolean isCompleted()
Description copied from interface:HttpAsyncExchange
Determines whether or not the message exchange has been completed.- Specified by:
isCompleted
in interfaceHttpAsyncExchange
- Returns:
true
if the message exchange has been completed,false
otherwise.
-
setTimeout
public void setTimeout(int timeout)
Description copied from interface:HttpAsyncExchange
Sets timeout for this message exchange.- Specified by:
setTimeout
in interfaceHttpAsyncExchange
-
getTimeout
public int getTimeout()
Description copied from interface:HttpAsyncExchange
Returns timeout for this message exchange.- Specified by:
getTimeout
in interfaceHttpAsyncExchange
-
-