http: don't keep alive close-delimited proxy responses#101
Open
Alexander4731 wants to merge 7 commits into
Open
http: don't keep alive close-delimited proxy responses#101Alexander4731 wants to merge 7 commits into
Alexander4731 wants to merge 7 commits into
Conversation
33b66f8 to
7297f95
Compare
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.
Summary
Fix HTTP proxy handling for close-delimited upstream responses.
The HTTP proxy inbound currently decides whether to keep the client connection alive from the client request's
Proxy-Connection: keep-alive, then overwrites the proxied response's close semantics.This breaks some legacy HTTP servers, especially HTTP/1.0 devices that return responses like:
These responses often do not include
Content-LengthorTransfer-Encoding; the response body is delimited by closing the connection. If the proxy rewrites the downstream response as keep-alive, clients may receive a truncated response or a reset connection before seeing headers such asWWW-Authenticate.Fix
Only keep the downstream HTTP proxy connection alive when:
This preserves the existing keep-alive behavior for length-delimited reusable responses, while keeping legacy close-delimited responses safe.
Reproduction
Using an HTTP proxy inbound or mixed inbound:
Before this change, a legacy HTTP/1.0 Basic Auth server can produce:
The same target via SOCKS5 succeeds because SOCKS5 forwards the TCP stream without rewriting the HTTP response:
Expected response:
Tests
Added tests for: