Repository navigation
fix: body truncation caused by async logging - #765
Merged
dwisiswant0 merged 2 commits intoSep 14, 2026
Merged
Conversation
Capture HTTP bodies as forwarding reads them and give the logger independent readers. This prevents logging from consuming bytes needed by the upstream server or downstream client. response processing could therefore read, replace, or close bodies while the transport was using them. Verbose request logging also consumed the body without restoring it. Setting ContentLength to -1 changed framing but did not resolve the shared reader ownership. Add a body capture wrapper that records forwarding reads and publishes immutable data when capture completes. Preserve read errors and forward Close to the original body without holding the capture lock, allowing Close to unblock an active Read. Retain the existing 4096-byte response log limit without limiting the forwarded response, and leave upgraded connections unwrapped. Queue metadata snapshots and capture handles. Retain the request capture in its context so response logs can include the request body after the transport consumes it. Use completed trailer copies instead of cloning live request trailers during an early response. Restore the private request body after verbose inspection for subsequent writers. Keep HAR processing on the original request pointer for Martian context lookup, before publishing the asynchronous transaction. Preserve its existing synchronous behavior and log-and-continue error handling. Preserve incoming ContentLength instead of forcing unknown length. When rebuilding a request after match-and-replace, copy ContentLength, TransferEncoding, and Trailer from the parsed request and clear GetBody so it cannot replay the old body. Fixes #749 Signed-off-by: Dwi Siswanto <git@dw1.io>
4 tasks done
Mzack9999
approved these changes
Sep 13, 2026
dwisiswant0
deleted the
dwisiswant0/fix/body-truncation-caused-by-async-logging
branch
September 14, 2026 01:12
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
Capture HTTP bodies as forwarding reads them and give the logger
independent readers. This prevents logging from consuming bytes needed
by the upstream server or downstream client.
response processing could therefore read, replace, or close bodies
while the transport was using them. Verbose request logging also
consumed the body without restoring it. Setting ContentLength to -1
changed framing but did not resolve the shared reader ownership.
Add a body capture wrapper that records forwarding reads and publishes
immutable data when capture completes. Preserve read errors and forward
Close to the original body without holding the capture lock, allowing
Close to unblock an active Read. Retain the existing 4096-byte response
log limit without limiting the forwarded response, and leave upgraded
connections unwrapped.
Queue metadata snapshots and capture handles. Retain the request
capture in its context so response logs can include the request body
after the transport consumes it. Use completed trailer copies instead
of cloning live request trailers during an early response. Restore the
private request body after verbose inspection for subsequent writers.
Keep HAR processing on the original request pointer for Martian context
lookup, before publishing the asynchronous transaction. Preserve its
existing synchronous behavior and log-and-continue error handling.
Preserve incoming ContentLength instead of forcing unknown length.
When rebuilding a request after match-and-replace, copy ContentLength,
TransferEncoding, and Trailer from the parsed request and clear GetBody
so it cannot replay the old body.
Fixes #749
Checklist