This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch BZ-63835/8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/BZ-63835/8.5.x by this push: new d758805 Properly determine requests left on a "keepAlive" connection d758805 is described below commit d7588053eba6699d17a1f4bf524597e0c1765fd9 Author: Michael Osipov <micha...@apache.org> AuthorDate: Fri Oct 11 12:51:44 2019 +0200 Properly determine requests left on a "keepAlive" connection --- java/org/apache/coyote/http11/Http11Processor.java | 8 +++++++- java/org/apache/tomcat/util/net/SocketWrapperBase.java | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index 3182bb7..78b1d7b 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -1386,7 +1386,13 @@ public class Http11Processor extends AbstractProcessor { String value = "timeout=" + TimeUnit.MILLISECONDS.toSeconds(keepAliveTimeout); if (maxKeepAliveRequests > 0) { - value += ", max=" + maxKeepAliveRequests; + /* + * We need to add 1 here because the value is already decremented in + * service() by 1. Otherwise the client would see 99 on the first request. + * In HTTPd this value is modified after this code block has been run. + */ + int left = socketWrapper.getKeepAliveLeft() + 1; + value += ", max=" + left; } headers.setValue("Keep-Alive").setString(value); diff --git a/java/org/apache/tomcat/util/net/SocketWrapperBase.java b/java/org/apache/tomcat/util/net/SocketWrapperBase.java index 658d4e4..556b05b 100644 --- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java +++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java @@ -170,8 +170,9 @@ public abstract class SocketWrapperBase<E> { } + public int getKeepAliveLeft() { return keepAliveLeft; } public void setKeepAliveLeft(int keepAliveLeft) { this.keepAliveLeft = keepAliveLeft;} - public int decrementKeepAlive() { return (--keepAliveLeft);} + public int decrementKeepAlive() { return (keepAliveLeft--);} public String getRemoteHost() { if (remoteHost == null) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org