Skip to content

fix(http): preserve binary download and stream output - #2778

Merged
chaliy merged 1 commit into
mainfrom
fix/http-binary-output
Oct 26, 2026
Merged

chaliy merged 1 commit into
mainfrom
fix/http-binary-output

Conversation

@chaliy

@chaliy chaliy commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What changed

curl preserves HTTP response bytes when writing files or stdout, including shell redirection, pipelines, and decompressed responses. wget -O - now preserves bytes too. Curl write-out counts use output bytes rather than replacement-expanded UTF-8 text.

Why

Binary downloads were decoded with String::from_utf8_lossy before reaching the filesystem or shell stream. Archives therefore failed to extract despite successful HTTP responses.

Before / After

Before: gzip magic 1f 8b 08 00 became 1f ef bf bd 08 00; an 8-byte response was reported as 14 bytes. A downloaded gzip archive failed with invalid gzip header.

After: raw bytes, NULs, and invalid UTF-8 survive files/stdout/pipelines. The same archive extracts successfully, and byte counts remain exact.

Validation: all 6 new HTTP integration tests pass (5 reproduced failures before the fix; the HTTP-error preservation control already passed). HTTP-feature all-target Clippy, formatting, cargo-vet, 183 Python tooling tests, knowledge/docs/capability/workflow/changelog guards pass. Full local suite: 2,593 passed, 4 ignored, 4 unchanged process-cleanup fixtures failed on ESRCH-absence assertions; those also fail serially in this runner, and a representative assertion reproduces with the unchanged upstream HTTP implementation. CI must pass before merge.

Changelog: Unreleased fix entry.

Risk

Low. HTTP policy, transport limits, credentials, and error handling stay on their existing path. The change removes early text decoding and uses the existing byte-native stream representation. Tests include HTTP failures preserving an existing destination file.

Checklist

  • Tests added or updated
  • Backward compatibility considered

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit adba7d0 Commit Preview URL

Branch Preview URL
Oct 26 2026, 04:08 AM

@chaliy
chaliy marked this pull request as ready for review October 26, 2026 04:32
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chaliy
chaliy merged commit 8541968 into main Oct 26, 2026
53 checks passed
@chaliy
chaliy deleted the fix/http-binary-output branch October 26, 2026 04:38
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.

1 participant