// allocate temporary buffers to process this request
context.setAttribute(REQUEST_BUFFER, ByteBuffer.allocate(cfg.getBufferZise()));
context.setAttribute(RESPONSE_BUFFER, ByteBuffer.allocate(cfg.getBufferZise()));
try {
PipeImpl requestPipe = new PipeImpl(); // the pipe used to process the request
PipeImpl responsePipe = new PipeImpl(); // the pipe used to process the response
context.setAttribute(REQUEST_SINK_CHANNEL, requestPipe.sink());
context.setAttribute(RESPONSE_SOURCE_CHANNEL, responsePipe.source());
// create the default response to this request
ProtocolVersion httpVersion = request.getRequestLine().getProtocolVersion();
HttpResponse response = responseFactory.newHttpResponse(
httpVersion, HttpStatus.SC_OK, context);
response.setParams(this.params);
// create a basic HttpEntity using the source channel of the response pipe
BasicHttpEntity entity = new BasicHttpEntity();
entity.setContent(Channels.newInputStream(responsePipe.source()));
if (httpVersion.greaterEquals(HttpVersion.HTTP_1_1)) {
entity.setChunked(true);
}
response.setEntity(entity);
// hand off processing of the request to a thread off the pool
workerPool.execute(
new ServerWorker(cfgCtx, conn, isHttps, this,
request, Channels.newInputStream(requestPipe.source()),
response, Channels.newOutputStream(responsePipe.sink())));
} catch (IOException e) {
handleException("Error processing request received for : " +
request.getRequestLine().getUri(), e, conn);
} catch (Exception e) {