ooeunz opened a new pull request, #1135:
URL: https://github.com/apache/tomcat/pull/1135

   ## Problem
   
   The HTTP/1.1 connector forces the connection to close after a response with 
a status code of 400, 408, 411, 413, 414, 500, 501 or 503 
(`Http11Processor.statusDropsConnection()`). When these responses are frequent, 
clients have to keep re-establishing connections, which increases HTTP resource 
usage. There is currently no way to turn this off.
   
   ## Change
   
   Add a `dropConnectionOnErrorStatus` attribute to the HTTP/1.1 connector. It 
defaults to `true`, so existing behaviour is unchanged.
   
   ```xml
   <Connector port="8080" protocol="HTTP/1.1" 
dropConnectionOnErrorStatus="false" />
   ```
   
   When set to `false`, a status code on its own no longer closes the 
connection. This applies to status codes set by an application or the 
container, such as `sendError(500)`.
   
   ## What still closes the connection
   
   Connections are still closed when re-using them would not be safe, whatever 
the value of the attribute:
   
   - The request could not be parsed, or is otherwise invalid (400).
   - The request uses an unsupported transfer encoding (501).
   - The connector is paused (503).
   - An exception is thrown during processing (500).
   - An error occurs after the response was committed.
   - The unread request body exceeds `maxSwallowSize`.
   - An `Expect: 100-continue` request body was not fully read.
   
   These responses still include `Connection: close`.
   
   ## Trade-off
   
   With the attribute set to `false`, a client that repeatedly triggers errors 
can hold a connection for longer, and Tomcat may swallow up to `maxSwallowSize` 
bytes of unread body per request. `maxKeepAliveRequests` and `keepAliveTimeout` 
still apply. This is why the default retains the current behaviour.
   
   ## Testing
   
   Added tests to `TestHttp11Processor` for:
   
   - the default behaviour
   - connection re-use with the attribute disabled
   - swallowing an unread body before the next request on the same connection
   - the cases above that must still close: invalid request line, missing 
`Host`, unsupported transfer encoding, and a body exceeding `maxSwallowSize`
   
   `ant validate` and the tests under `org.apache.coyote.http11` pass on NIO 
with JDK 21. The full test suite was not run.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to