You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mi...@apache.org on 2019/10/23 14:23:28 UTC

[tomcat] 01/01: BZ 63835: Add support for Keep-Alive header

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch BZ-63835/9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 38fdae10298cfd239e25428319522b0c8ae70087
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Oct 23 15:37:42 2019 +0200

    BZ 63835: Add support for Keep-Alive header
---
 java/org/apache/coyote/http11/Http11Processor.java | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java
index 7be52d0..262cc8c 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -915,8 +915,26 @@ public class Http11Processor extends AbstractProcessor {
                 headers.addValue(Constants.CONNECTION).setString(
                         Constants.CLOSE);
             }
-        } else if (!http11 && !getErrorState().isError()) {
-            headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
+        } else if (!getErrorState().isError()) {
+            if (!http11) {
+                headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
+            }
+
+            boolean connectionKeepAlivePresent =
+                isConnectionToken(request.getMimeHeaders(), Constants.KEEPALIVE);
+
+            if (connectionKeepAlivePresent) {
+                int keepAliveTimeout = protocol.getKeepAliveTimeout();
+
+                if (keepAliveTimeout > 0) {
+                    String value = "timeout=" + keepAliveTimeout / 1000L;
+                    headers.setValue("Keep-Alive").setString(value);
+                }
+
+                if (http11) {
+                    headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
+                }
+            }
         }
 
         // Add server header


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org