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.AtomicBooleancompletedprivate NHttpServerConnectionconnprivate HttpContextcontextprivate HttpRequestrequestprivate HttpResponseresponseprivate HttpAsyncService.Statestate
-
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 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.
-
-
-
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:HttpAsyncExchangeReturns the received HTTP request message.- Specified by:
getRequestin interfaceHttpAsyncExchange- Returns:
- received HTTP request message.
-
getResponse
public HttpResponse getResponse()
Description copied from interface:HttpAsyncExchangeReturns the default HTTP response message. Once ready the response message can submitted usingHttpAsyncExchange.submitResponse()method.- Specified by:
getResponsein interfaceHttpAsyncExchange- Returns:
- default HTTP response message.
-
setCallback
public void setCallback(Cancellable cancellable)
Description copied from interface:HttpAsyncExchangeSetsCancellablecallback 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:
setCallbackin interfaceHttpAsyncExchange
-
submitResponse
public void submitResponse(HttpAsyncResponseProducer responseProducer)
Description copied from interface:HttpAsyncExchangeSubmits an HTTP response using a customHttpAsyncResponseProducer.- Specified by:
submitResponsein interfaceHttpAsyncExchange
-
submitResponse
public void submitResponse()
Description copied from interface:HttpAsyncExchangeSubmits 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.- Specified by:
submitResponsein interfaceHttpAsyncExchange
-
isCompleted
public boolean isCompleted()
Description copied from interface:HttpAsyncExchangeDetermines whether or not the message exchange has been completed.- Specified by:
isCompletedin interfaceHttpAsyncExchange- Returns:
trueif the message exchange has been completed,falseotherwise.
-
setTimeout
public void setTimeout(int timeout)
Description copied from interface:HttpAsyncExchangeSets timeout for this message exchange.- Specified by:
setTimeoutin interfaceHttpAsyncExchange
-
getTimeout
public int getTimeout()
Description copied from interface:HttpAsyncExchangeReturns timeout for this message exchange.- Specified by:
getTimeoutin interfaceHttpAsyncExchange
-
-