tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Wehle <j...@feith.com>
Subject Patch for tomcat 5.5.25 to actually close on Connection: close
Date Thu, 24 Jan 2008 22:11:55 GMT
Currently if a servlet uses:

  res.setHeader("Connection", "close");

tomcat just sets the header and sends the reponse to the client.  It
then waits for the client to close the connection.  In some cases (i.e.
buggy client) the client doesn't process the close which causes resources
to be unduly tied up on the server until the connectionTimeout is reached
which then closes the connection.  This also causes the user to experience
a browser delay corresponding to connectionTimeout.

This patches causes tomcat to close a connection after sending a response
which includes "Connection: close".

-- John Wehle
------------------8<------------------------8<------------------------
*** connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java.ORIGINAL	Wed
Jan 23 18:35:31 2008
--- connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java	Thu Jan 24 16:21:36
2008
*************** public class Http11Processor implements 
*** 923,928 ****
--- 923,938 ----
              }
              request.updateCounters();
  
+             MimeHeaders headers = response.getMimeHeaders();
+ 
+             // Check connection header
+             MessageBytes connectionValueMB = headers.getValue("connection");
+             if (connectionValueMB != null) {
+                 if (connectionValueMB.equalsIgnoreCase(Constants.CLOSE)) {
+                     keepAlive = false;
+                 }
+             }
+ 
              thrA.setCurrentStage(threadPool, "ended");
              rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
  
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


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


Mime
View raw message