mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-19 02:14:59 +00:00
perf[net]: http协议头部KEEP_ALIVE
This commit is contained in:
1 parent
939a43ff91
commit
64a67b414b
1 file changed
+4
-1
@@ -75,6 +75,7 @@ public class HttpCodecHandler extends MessageToMessageCodec<FullHttpRequest, Enc
|
|||||||
var fullHttpResponse = new DefaultFullHttpResponse(protocolVersion, httpResponseStatus);
|
var fullHttpResponse = new DefaultFullHttpResponse(protocolVersion, httpResponseStatus);
|
||||||
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);
|
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);
|
||||||
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_LENGTH, 0);
|
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_LENGTH, 0);
|
||||||
|
fullHttpResponse.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);
|
||||||
list.add(fullHttpResponse);
|
list.add(fullHttpResponse);
|
||||||
} else {
|
} else {
|
||||||
var byteBuf = channelHandlerContext.alloc().ioBuffer();
|
var byteBuf = channelHandlerContext.alloc().ioBuffer();
|
||||||
@@ -83,7 +84,7 @@ public class HttpCodecHandler extends MessageToMessageCodec<FullHttpRequest, Enc
|
|||||||
|
|
||||||
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);
|
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);
|
||||||
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_LENGTH, byteBuf.readableBytes());
|
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_LENGTH, byteBuf.readableBytes());
|
||||||
|
fullHttpResponse.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);
|
||||||
list.add(fullHttpResponse);
|
list.add(fullHttpResponse);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -94,6 +95,8 @@ public class HttpCodecHandler extends MessageToMessageCodec<FullHttpRequest, Enc
|
|||||||
|
|
||||||
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON);
|
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON);
|
||||||
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_LENGTH, byteBuf.readableBytes());
|
fullHttpResponse.headers().set(HttpHeaderNames.CONTENT_LENGTH, byteBuf.readableBytes());
|
||||||
|
fullHttpResponse.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);
|
||||||
|
// fullHttpResponse.headers().set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
|
||||||
|
|
||||||
list.add(fullHttpResponse);
|
list.add(fullHttpResponse);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user