Repository navigation
Conversation
… body The handler reads the upstream body with aread(), which decompresses it, and drops Content-Encoding, but kept the upstream Content-Length: the length of the compressed body. Starlette's Response keeps a given Content-Length, so the client was told the wrong length. The handler now drops it with Content-Encoding, and Response sets the length of the body it sends.
This branch has not been deployed
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.
The reverse proxy handler reads the upstream body with
aread(), which decompresses it, and dropsContent-Encoding. It keeps the upstreamContent-Length, which is the compressed size. WithENABLE_COMPRESSION=false, a client that sendsAccept-Encoding: gzipgets the wrong length on routes no middleware rewrites, like/conformance. Uvicorn then raises h11'sLocalProtocolErrorand cuts the connection. The proxy's default compression hides this because it compresses the body again.This drops
Content-LengthwithContent-Encoding, so Starlette'sResponsesets the real length.The new test fails on
main: it gets 38 declared for an 18-byte body.pytestpasses (763), and so do the pre-commit hooks.