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: [EMAIL PROTECTED]  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to