Package org.apache.http.nio.protocol
Class BasicAsyncRequestHandler
- java.lang.Object
-
- org.apache.http.nio.protocol.BasicAsyncRequestHandler
-
- All Implemented Interfaces:
HttpAsyncRequestHandler<HttpRequest>
@Contract(threading=IMMUTABLE_CONDITIONAL) public class BasicAsyncRequestHandler extends java.lang.Object implements HttpAsyncRequestHandler<HttpRequest>
Basic implementation ofHttpAsyncRequestHandler
that delegates the process of request handling to aHttpRequestHandler
. Please note that this handler buffers request content in memory and should be used for relatively small request messages.- Since:
- 4.2
-
-
Constructor Summary
Constructors Constructor Description BasicAsyncRequestHandler(HttpRequestHandler handler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handle(HttpRequest request, HttpAsyncExchange httpexchange, HttpContext context)
Triggered to complete request processing and to initiate the process of generating a response.HttpAsyncRequestConsumer<HttpRequest>
processRequest(HttpRequest request, HttpContext context)
Triggered when an incoming request is received.
-
-
-
Constructor Detail
-
BasicAsyncRequestHandler
public BasicAsyncRequestHandler(HttpRequestHandler handler)
-
-
Method Detail
-
processRequest
public HttpAsyncRequestConsumer<HttpRequest> processRequest(HttpRequest request, HttpContext context)
Description copied from interface:HttpAsyncRequestHandler
Triggered when an incoming request is received. This method should return aHttpAsyncRequestConsumer
that will be used to process the request and consume message content if enclosed. The consumer can optionally parse or transform the message content into a structured object which is then passed onto theHttpAsyncRequestHandler.handle(Object, HttpAsyncExchange, HttpContext)
method for further processing.- Specified by:
processRequest
in interfaceHttpAsyncRequestHandler<HttpRequest>
- Parameters:
request
- the entity enclosing request.context
- the execution context.- Returns:
- request consumer.
-
handle
public void handle(HttpRequest request, HttpAsyncExchange httpexchange, HttpContext context) throws HttpException, java.io.IOException
Description copied from interface:HttpAsyncRequestHandler
Triggered to complete request processing and to initiate the process of generating a response. This method does not have to submit a response immediately. It can defer transmission of an HTTP response back to the client without blocking the I/O thread by delegating the process of request handling to another service or a worker thread. HTTP response can be submitted as a later a later point of time usingHttpAsyncExchange
once response content becomes available.- Specified by:
handle
in interfaceHttpAsyncRequestHandler<HttpRequest>
- Parameters:
request
- request data returned by the request consumer.httpexchange
- HTTP exchange.context
- HTTP execution context.- Throws:
HttpException
- in case of HTTP protocol violation or a processing problem.java.io.IOException
- in case of an I/O error.
-
-