Add http header connection close (#2432)

This commit is contained in:
Joey777210
2023-04-18 17:53:34 +08:00
committed by GitHub
parent 304d51d2e3
commit 8024aca4cf
@@ -125,6 +125,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ
// try to add content-length header for DefaultFullHttpResponse
if (!HttpUtil.isTransferEncodingChunked(response)
&& response instanceof DefaultFullHttpResponse) {
response.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE);
response.headers().set(HttpHeaderNames.CONTENT_LENGTH,
((DefaultFullHttpResponse) response).content().readableBytes());
return ctx.writeAndFlush(response);