Skip to content

Commit aae805e

Browse files
committed
optimize: support http1 automatic keepalive setting
1 parent 0e0216d commit aae805e

File tree

1 file changed

+4
-4
lines changed
  • dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1

1 file changed

+4
-4
lines changed

dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Codec.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
public class NettyHttp1Codec extends ChannelDuplexHandler {
4646

47-
boolean keepAlive;
47+
private boolean keepAlive;
4848

4949
@Override
5050
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
@@ -97,10 +97,10 @@ private void doWriteHeader(ChannelHandlerContext ctx, HttpMetadata msg, ChannelP
9797

9898
private void doWriteMessage(ChannelHandlerContext ctx, HttpOutputMessage msg, ChannelPromise promise) {
9999
if (HttpOutputMessage.EMPTY_MESSAGE == msg) {
100-
if (!keepAlive) {
101-
ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT, promise).addListener(ChannelFutureListener.CLOSE);
102-
} else {
100+
if (keepAlive) {
103101
ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT, promise);
102+
} else {
103+
ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT, promise).addListener(ChannelFutureListener.CLOSE);
104104
}
105105
return;
106106
}

0 commit comments

Comments
 (0)