You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by John Wehle <jo...@feith.com> on 2008/01/24 23:11:55 UTC

Patch for tomcat 5.5.25 to actually close on Connection: close

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


Re: Patch for tomcat 5.5.25 to actually close on Connection: close

Posted by Peter Rossbach <pr...@objektpark.de>.
Hi Remy,

True, but today it exists a lot of applications/Service that want  
control the connection.
At my Comet example I have also miss this simple feature.
I feel that the patch looks good.

Peter



Am 25.01.2008 um 13:14 schrieb Remy Maucherat:

> On Thu, 2008-01-24 at 17:11 -0500, John Wehle wrote:
>> 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".
>
> The rationale is that a servlet has no business dealing with the
> connection behavior: if the client has problems, you can add  
> appropriate
> configuration in the connector.
>
> Rémy
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>


Re: Patch for tomcat 5.5.25 to actually close on Connection: close

Posted by Remy Maucherat <re...@apache.org>.
On Thu, 2008-01-24 at 17:11 -0500, John Wehle wrote:
> 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".

The rationale is that a servlet has no business dealing with the
connection behavior: if the client has problems, you can add appropriate
configuration in the connector.

Rémy



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