Skip to content

fix: decode Transfer-Encoding: chunked request bodies - #50

Open
maddie wants to merge 1 commit into
librespeed:masterfrom
maddie:fix/chunked-body-parsing
Open

fix: decode Transfer-Encoding: chunked request bodies#50
maddie wants to merge 1 commit into
librespeed:masterfrom
maddie:fix/chunked-body-parsing

Conversation

@maddie

@maddie maddie commented Aug 17, 2026

Copy link
Copy Markdown

Problem

The BodyType::Chunked branch (src/http/request.rs) read the raw stream in fixed 1024-byte read_exact blocks and never chunk-decoded it. With a finite payload the client keeps the connection open (keep-alive, no half-close), the final block never fills, and the server blocks forever instead of answering — hanging any chunked uploader after its first payload.

Concrete case: librespeed/speedtest-cli#122 — librespeed-cli uploads at 0.55 Mbps against librespeed-rs (one 1 MiB payload / 15 s duration). Same stall reproduces with curl -H "Transfer-Encoding: chunked" --data-binary @file.

See librespeed/speedtest-rust#49 for the full analysis (server log: CHUNKED: read 1048837 raw bytes, then EOF/blocked — 1024×1024 payload + 261 bytes of chunk framing is not a multiple of the 1024-byte read block).

Fix

Decode the chunked framing per RFC 9112 §7.1: read the chunk-size line (extensions after ; ignored), the chunk data, and the trailing CRLF per chunk; stop at the 0-size last chunk and consume the trailer section up to the blank line.

Verification

Closes #49

The Chunked body branch read the raw stream in fixed 1024-byte blocks and
never decoded it. With a finite payload the client keeps the connection
open (keep-alive, no half-close), the final block never fills, and the
server blocks forever instead of answering — hanging any chunked uploader
after its first payload (librespeed#49, root cause of
librespeed/speedtest-cli#122).

Parse the chunked framing per RFC 9112 §7.1: chunk-size line (extensions
ignored), chunk data, trailing CRLF, then the 0-size last chunk and the
trailer section. Verified with curl -H 'Transfer-Encoding: chunked' (1 MiB
body): 200 OK in ~1 ms where it previously hung.
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.

Upload requests with Transfer-Encoding: chunked hang forever

1 participant