Repository navigation
close connection after http/1.0 request with transfer-encoding - #751
Open
rootvector2 wants to merge 2 commits into
Open
rootvector2 wants to merge 2 commits into
rootvector2 wants to merge 2 commits into
Conversation
ok2c
reviewed
Nov 20, 2026
| @@ -85,6 +85,12 @@ public boolean keepAlive( | |||
| if (request.containsHeader(HttpHeaders.CONTENT_LENGTH) && request.containsHeader(HttpHeaders.TRANSFER_ENCODING)) { | |||
Member
There was a problem hiding this comment.
@rootvector2 Let's optimize it a bit and execute CONTENT_LENGTH and TRANSFER_ENCODING checks only once
final boolean contentLenPresent = request.containsHeader(HttpHeaders.CONTENT_LENGTH);
final boolean transferEncodingPresent = request.containsHeader(HttpHeaders.TRANSFER_ENCODING);
if (contentLenPresent && transferEncodingPresent) {
...
Author
There was a problem hiding this comment.
Done. Both lookups are now hoisted into contentLenPresent and transferEncodingPresent and the two checks reuse them.
ok2c
reviewed
Nov 20, 2026
| // Consider framing of a HTTP/1.0 request message with Transfer-Encoding header faulty | ||
| final ProtocolVersion requestVersion = request.getVersion(); | ||
| if (requestVersion != null && requestVersion.lessEquals(HttpVersion.HTTP_1_0) | ||
| && request.containsHeader(HttpHeaders.TRANSFER_ENCODING)) { |
Author
There was a problem hiding this comment.
Fixed, the HTTP/1.0 check now reuses transferEncodingPresent instead of calling containsHeader again.
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.
DefaultConnectionReuseStrategy.keepAlivetreats an HTTP/1.0 response withTransfer-Encodingas faulty framing, but not an HTTP/1.0 request. The server still decodesPOST / HTTP/1.0withTransfer-Encoding: chunkedandConnection: keep-aliveas chunked, keeps the connection open, and parses the bytes after the body as the next request. An HTTP/1.0 intermediary doesn't knowTransfer-Encodingand frames that request differently. I found this by reading the reuse strategy against RFC 9112 section 6.1 and confirmed it on the classic server with a raw socket: before the fix a pipelinedGETafter such a request reaches the handler, and after it the connection closes once the first response is sent.The fix adds the request-side rule from RFC 9112 section 6.1, next to the existing check for a request with both
Content-LengthandTransfer-Encoding. It's a single header lookup per exchange and applies only to HTTP/1.0 requests, so HTTP/1.1 traffic is unaffected.testRequestHTTP10TransferEncodingPresentcovers it.