Repository navigation
fix(proxy): preserve streamed request bodies - #764
Closed
beyondlong wants to merge 1 commit into
Closed
beyondlong wants to merge 1 commit into
beyondlong wants to merge 1 commit into
Conversation
beyondlong
force-pushed
the
fix/post-body-stream
branch
from
September 8, 2026 09:05
ed91842 to
2ad90d7
Compare
dwisiswant0
requested changes
Sep 13, 2026
dwisiswant0
left a comment
Member
There was a problem hiding this comment.
This patch separates the initial request reader, but io.PipeWriter.Write blocks forwarding until the logger consumes each write, and LogResponse still queues the live response and original request. Removing the forced unknown length also leaves match-and-replace requests with potentially stale framing metadata.
I'm superseding this patch with #765, which addresses body ownership across both request and response logging.
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.
Proposed changes
Fixes #749.
ModifyRequestforcedContentLengthto-1, while the asynchronous logger and HTTP transport both consumed the same live request body. The reader that lost that race received an empty body; in the reported case, the upstream server saw an empty chunked POST.This change preserves the request's original content length and gives the asynchronous logger an independent streaming reader backed by
io.Pipe. The upstream transport remains the source reader, so the request body is copied to logging as it is forwarded. If the logging reader closes, forwarding continues. This also avoids buffering attacker-controlled bodies in memory, which was the security issue identified on the earlier implementation in #750.Regression coverage verifies:
Content-Lengthreach a realhttptestupstream without forced chunked encoding;Verification:
Disclosure: the implementation and tests were prepared with Codex assistance and reviewed and verified locally by the contributor.
Checklist