ChristopherSchultz commented on a change in pull request #218: WIP: BZ 63835: 
Add support for Keep-Alive header
URL: https://github.com/apache/tomcat/pull/218#discussion_r338613581
 
 

 ##########
 File path: java/org/apache/coyote/http11/Http11Processor.java
 ##########
 @@ -915,8 +915,26 @@ protected final void prepareResponse() throws IOException 
{
                 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);
 
 Review comment:
   Sending `Connection: keep-alive` without a `Keep-Alive: ...` header is 
reasonable.
   
   I _think_ the way this should work is this:
   * If client sends `Connection: keep-alive` header _or_ no `Connection` 
header is found, set `Connection: keep-alive` on the response (or maybe for 
HTTP/1.0 it defaults to `Connection: close`?)
   * If client sends `Connection: keep-alive` header _and_ it's using HTTP/1.1, 
then also set `Keep-Alive: ...` on the response

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to