HttpRequest request, NettyHttpContextHandler nettyHttpContextHandler)
throws Exception {
interceptOnRequestReceived(ctx, request);
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
NettyServletResponse nettyServletResponse = buildHttpServletResponse(response);
NettyHttpServletRequest nettyServletRequest =
buildHttpServletRequest(request, nettyHttpContextHandler.getContextPath(), ctx);
nettyHttpContextHandler.handle(nettyServletRequest.getRequestURI(), nettyServletRequest, nettyServletResponse);
interceptOnRequestSuccessed(ctx, response);
nettyServletResponse.getWriter().flush();
boolean keepAlive = HttpHeaders.isKeepAlive(request);
if (keepAlive) {
// Add 'Content-Length' header only for a keep-alive connection.
response.headers().set(Names.CONTENT_LENGTH, response.content().readableBytes());
// Add keep alive header as per:
// -
// http://www.w3.org/Protocols/HTTP/1.1/draft-ietf-http-v11-spec-01.html#Connection
response.headers().set(Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
}
// write response...
ChannelFuture future = ctx.write(response);