This is an automated email from the ASF dual-hosted git repository. suncairong pushed a commit to branch 3.2 in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push: new d32ad7906d optimize: rest protocol connection default keepalive (#14543) d32ad7906d is described below commit d32ad7906dc4ece1f76519d1dc0ba6d9812633dd Author: funkye <jian...@apache.org> AuthorDate: Fri Aug 16 18:15:57 2024 +0800 optimize: rest protocol connection default keepalive (#14543) * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive * optimize: rest protocol connection default keepalive --- .../dubbo/remoting/http/restclient/URLConnectionRestClient.java | 1 - .../org/apache/dubbo/rpc/protocol/rest/netty/ChunkOutputStream.java | 6 ++---- .../dubbo/rpc/protocol/rest/netty/RestHttpRequestDecoder.java | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/URLConnectionRestClient.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/URLConnectionRestClient.java index 54d106bc51..65f20a19f2 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/URLConnectionRestClient.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/URLConnectionRestClient.java @@ -47,7 +47,6 @@ public class URLConnectionRestClient implements RestClient { try { HttpURLConnection connection = (HttpURLConnection) new URL(requestTemplate.getURL()).openConnection(); - requestTemplate.addHeader("connection", "close"); connection.setConnectTimeout(clientConfig.getConnectTimeout()); connection.setReadTimeout(clientConfig.getReadTimeout()); connection.setRequestMethod(requestTemplate.getHttpMethod()); diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/netty/ChunkOutputStream.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/netty/ChunkOutputStream.java index 9cafc0a84e..8f4fd78253 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/netty/ChunkOutputStream.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/netty/ChunkOutputStream.java @@ -67,12 +67,10 @@ public class ChunkOutputStream extends OutputStream { @Override public void write(byte[] b, int off, int len) throws IOException { - int dataLengthLeftToWrite = len; - int dataToWriteOffset = off; - if (buffer.maxWritableBytes() < dataLengthLeftToWrite) { + if (buffer.maxWritableBytes() < len) { throwExceedPayloadLimitException(buffer.readableBytes() + len); } - buffer.writeBytes(b, dataToWriteOffset, dataLengthLeftToWrite); + buffer.writeBytes(b, off, len); } @Override diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/netty/RestHttpRequestDecoder.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/netty/RestHttpRequestDecoder.java index f89d229d9a..753bc09a17 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/netty/RestHttpRequestDecoder.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/netty/RestHttpRequestDecoder.java @@ -21,7 +21,6 @@ import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.threadpool.manager.ExecutorRepository; import org.apache.dubbo.common.utils.ExecutorUtil; -import org.apache.dubbo.rpc.protocol.rest.RestHeaderEnum; import org.apache.dubbo.rpc.protocol.rest.deploy.ServiceDeployer; import org.apache.dubbo.rpc.protocol.rest.handler.NettyHttpHandler; import org.apache.dubbo.rpc.protocol.rest.request.NettyRequestFacade; @@ -74,7 +73,6 @@ public class RestHttpRequestDecoder extends MessageToMessageDecoder<io.netty.han } finally { // write response try { - nettyHttpResponse.addOutputHeaders(RestHeaderEnum.CONNECTION.getHeader(), "close"); nettyHttpResponse.finish(); } catch (IOException e) { logger.error(