Show the request body in the failure dump - #82
Merged
Conversation
korya
force-pushed
the
korya-fix-bare-header
branch
from
August 8, 2026 13:15
f058f11 to
8d2bc4a
Compare
korya
force-pushed
the
korya-fix-request-body-dump
branch
from
August 8, 2026 13:15
0601193 to
790f7fa
Compare
korya
force-pushed
the
korya-fix-bare-header
branch
from
August 8, 2026 13:20
8d2bc4a to
77c0cc5
Compare
korya
force-pushed
the
korya-fix-request-body-dump
branch
from
August 8, 2026 13:20
790f7fa to
43bdce4
Compare
The dump advertised a Content-Length and shipped nothing behind it:
FAILED: POST http://…/echo (HTTP/1.1)
POST /echo HTTP/1.1
Host: 127.0.0.1:8791
User-Agent: Go-http-client/1.1
Content-Length: 24 <- claims 24 bytes
<- ships zero
After a failed POST the first question is what was actually sent, and
that was the one thing the report left out. It was also not a valid HTTP
message, so it could not be replayed or pasted anywhere useful.
The cause is that the request is rendered after the send, and the send
consumes req.Body. Cloning it through GetBody replays the payload; the
machinery arrived with --retry, which already needed a fresh request per
attempt.
Rendering no longer goes through http.Request.Write alone, for the same
reason writeTo stopped going through http.Response.Write in #18: it is a
wire-format serializer, so a 5MB -d would have landed in the report
whole and a binary one would have gone to the terminal raw. The headers
still come from Write, which knows what actually goes on the wire --
Host, User-Agent and Content-Length are none of them in req.Header --
and the body now goes through the same renderer as the response, so it
crops at 256 bytes and hex-dumps when it is not text.
A request with no body renders as it did. A body that cannot be replayed
falls back to headers alone rather than failing the dump, because a
failed dump must not replace the failure being reported.
Closes #19
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EMMhgmTkbzAsmeNy97PrP
korya
force-pushed
the
korya-fix-request-body-dump
branch
from
August 8, 2026 13:23
43bdce4 to
09f4f91
Compare
korya
marked this pull request as ready for review
August 8, 2026 13:24
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.
Problem
After a failed POST the dump left out the one thing you need: what was sent.
Two problems in one. The payload is missing when it is the first question anyone asks, and what is printed is not a valid HTTP message — it cannot be replayed, pasted into a bug report, or fed to anything that parses HTTP.
The cause is ordering: the request is rendered after it has been sent, and sending consumes
req.Body.Solution
Clone the request through
GetBodybefore rendering it, and stop usinghttp.Request.Writeas a pretty-printer.The replay machinery already existed —
--retryneeded a fresh request per attempt, socloneForAttemptwas already there and already tested. This is a second caller for it.Why not just re-attach the body and let
Writedo itThat fixes the missing payload and reintroduces #18.
http.Request.Writeis a wire-format serializer: a 5MB-dwould land in the report whole, and a binary one would go to the terminal raw.writeTostopped usinghttp.Response.Writefor exactly that reason, and the request half never got the same treatment.So the split is: headers from
Write, which knows what actually goes on the wire —Host,User-AgentandContent-Lengthare none of them inreq.Header, so hand-rendering would silently lose the very header this issue is about — and the body through the same renderer as the response.A request with no body renders exactly as before. A body that cannot be replayed — no
GetBody— falls back to headers alone rather than failing, because a broken dump must not replace the failure being reported.Other Changes
TestKnownIssue19RequestBodyMissingis deleted, replaced byTestE2EDumpShowsTheRequestBody: the payload appears, it survives a--retry(the dump records one exchange, so it must outlast however many attempts it took), long payloads crop, binary payloads hex-dump, and a body-less GET is untouched.Test_writeRequestcovers the same five at the unit level against a request drained the wayhttp.Clientdrains it, so the state under test is the state the dump actually receives rather than a fresh request that would pass trivially.Note on binary payloads: a NUL byte cannot reach
-dat all, sinceexecrejects it in an argument. The tests use\xff\xfe\x07\x08, which is reachable and equally non-printable.There are no screenshots because there is no rendered UI; this tool's user-visible surface is terminal output, shown inline above.
Closes #19
Related:
🤖 Generated with Claude Code
https://claude.ai/code/session_019EMMhgmTkbzAsmeNy97PrP