Fix Proxy to correctly forward Transfer-Encoding: chunked responses - #835
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix proxy handling for transfer-encoding chunked data
Fix Proxy to correctly forward Transfer-Encoding: chunked responses
Jul 15, 2026
Member
|
@copilot Since you Smoke-tested it; can you make that into a unit test. |
ademar
approved these changes
Jul 15, 2026
Contributor
Author
Done in ce0dc25 — added |
ademar
approved these changes
Jul 15, 2026
ademar
marked this pull request as ready for review
July 15, 2026 17:58
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.
Suave.Proxyforwarded the origin'sTransfer-Encoding: chunkedheader verbatim while streaming the body fromHttpWebResponse.GetResponseStream(), which transparently de-chunks. Clients received achunkedresponse whose payload was not actually chunked, e.g.curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding.Changes in
src/Suave/Proxy.fschunkedas a comma-separated token (case-insensitive) inTransfer-Encoding, not a substring — avoids false positives from values likegzip, chunkedbeing treated correctly and rules out spurious matches.Transfer-Encodingand the mutually-exclusiveContent-Lengthfrom the forwarded header set before re-addingTransfer-Encoding: chunked.transferStreamChunkedhelper (same one used byokStreamChunked), instead of writing the de-chunked bytes raw.Content-Length/ close-delimited path unchanged.Verification
Smoke-tested against a hand-rolled upstream that emits
Transfer-Encoding: chunkedwith a multi-chunk body: the proxy output now contains a singleTransfer-Encoding: chunked, noContent-Length, and correctly framed chunks terminated by0\r\n\r\n.Known limitation (out of scope)
Exotic stacks like
Transfer-Encoding: gzip, chunked(gzip applied as a transfer coding rather thanContent-Encoding) will lose thegziplayer since the entire header is dropped. This encoding form is essentially unused in practice; happy to extend if reviewers want it preserved.