Skip to content

client: preserve request bodies before downloading - #115

Open
omrzk wants to merge 1 commit into
cavaliergopher:mainfrom
omrzk:fix/preserve-request-bodies-93
Open

omrzk wants to merge 1 commit into
cavaliergopher:mainfrom
omrzk:fix/preserve-request-bodies-93

Conversation

@omrzk

@omrzk omrzk commented Oct 29, 2026

Copy link
Copy Markdown

The preliminary HEAD request shallow-copies the download request, including its body. That can consume the body before the POST/GET download, and an in-memory download can finish using the HEAD response without issuing the requested method at all.

Only probe bodyless GET requests. Send other methods and body-bearing requests directly, preserving the caller's method and body. Fixes #93.

Validation on Linux / Go 1.26.10:

  • Four loopback HTTP regressions fail on upstream: in-memory POST, streaming POST to a file, non-replayable GET, and POST through a 307 redirect. They pass after the change and across 20 race repetitions.
  • make check passes: formatting, vet, pinned staticcheck, tidy, complete shuffled race/coverage suites, and CLI build.
  • CLI smoke tests pass for a byte-identical 1 MiB loopback download and a failing 404 download. Linux/macOS/Windows/FreeBSD builds pass for amd64 and arm64; these are cross-builds, not native execution.
  • govulncheck v1.9.0 reports no vulnerabilities with this toolchain.

Only send preliminary HEAD probes for bodyless GET requests. A probe
otherwise consumes and closes the shared body or becomes the final
response for an in-memory download, skipping the requested method.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http: ContentLength=111 with Body length 0

1 participant