Skip to content

Request body is never shown in the failure dump (and Content-Length contradicts it) #19

Description

@korya

Problem

writeHttpDetails calls req.Write(w) after the transport has already drained the request body reader, so the dump shows headers with a non-zero Content-Length and no body.

Reproduction

$ http-assert -X POST -d 'THIS-IS-THE-REQUEST-BODY' --assert-status 999 http://127.0.0.1:8791/echo
…
FAILED: POST http://127.0.0.1:8791/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

Why it matters

When a POST assertion fails, the first question is "what did I actually send?" — and that is exactly what the dump omits. The output is also self-contradictory as an HTTP message.

Affected code

main.go — Client.writeHttpDetails, called from Client.Do

Suggested fix

Buffer the -d payload and set req.GetBody, then re-attach a fresh reader before dumping (or keep the raw string alongside the request and print it explicitly).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions