nettyRequest.release();
return;
}
final long startTime = addResponseTimeHeader ? System.nanoTime() : 0;
final Request request = new DefaultRequest(new NettyHeadersBackedHeaders(nettyRequest.headers()), nettyRequest.getMethod().name(), nettyRequest.getUri(), nettyRequest.content());
final Channel channel = ctx.channel();
final HttpHeaders nettyHeaders = new DefaultHttpHeaders(false);
final MutableHeaders responseHeaders = new NettyHeadersBackedMutableHeaders(nettyHeaders);
final DefaultEventController<RequestOutcome> requestOutcomeEventController = new DefaultEventController<>();
final AtomicBoolean transmitted = new AtomicBoolean(false);
final DefaultResponseTransmitter responseTransmitter = new DefaultResponseTransmitter(transmitted, execControl, channel, nettyRequest, request, nettyHeaders, requestOutcomeEventController, launchConfig.isCompressResponses(), shouldCompress, startTime);
final Response response = new DefaultResponse(execControl, responseHeaders, ctx.alloc(), responseTransmitter);
ctx.attr(RESPONSE_TRANSMITTER_ATTRIBUTE_KEY).set(responseTransmitter);
InetSocketAddress socketAddress = (InetSocketAddress) channel.localAddress();
final BindAddress bindAddress = new InetSocketAddressBackedBindAddress(socketAddress);
Action<Action<Object>> subscribeHandler = thing -> {
transmitted.set(true);
channelSubscriptions.put(channel, thing);
channel.closeFuture().addListener(future -> channelSubscriptions.remove(channel));
};
final DirectChannelAccess directChannelAccess = new DefaultDirectChannelAccess(channel, subscribeHandler);
final DefaultContext.RequestConstants requestConstants = new DefaultContext.RequestConstants(
applicationConstants, bindAddress, request, response, directChannelAccess, requestOutcomeEventController.getRegistry()
);
DefaultContext.start(execController.getControl(), requestConstants, registry, handlers, execution -> {
if (!transmitted.get()) {
Handler lastHandler = requestConstants.handler;
StringBuilder description = new StringBuilder();
description
.append("No response sent for ")
.append(request.getMethod().getName())
.append(" request to ")
.append(request.getUri())
.append(" (last handler: ");
if (lastHandler instanceof DescribingHandler) {
((DescribingHandler) lastHandler).describeTo(description);
} else {