Repository navigation
Conversation
The HTTP/1.1 connector closes the connection after a response with a status code of 400, 408, 411, 413, 414, 500, 501 or 503. Clients then have to re-establish the connection, which increases HTTP resource usage when these responses are frequent. Add the dropConnectionOnErrorStatus connector attribute so this behaviour can be disabled. The default of true retains the current behaviour. Connections are still closed when it is not safe to re-use them.
Contributor
|
No. See #579. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
dropConnectionOnErrorStatusattribute to the HTTP/1.1 connector. It defaults totrue, so existing behaviour is unchanged.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 assendError(500).What still closes the connection
Connections are still closed when re-using them would not be safe, whatever the value of the attribute:
maxSwallowSize.Expect: 100-continuerequest 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 tomaxSwallowSizebytes of unread body per request.maxKeepAliveRequestsandkeepAliveTimeoutstill apply. This is why the default retains the current behaviour.Testing
Added tests to
TestHttp11Processorfor:Host, unsupported transfer encoding, and a body exceedingmaxSwallowSizeant validateand the tests underorg.apache.coyote.http11pass on NIO with JDK 21. The full test suite was not run.