deno
dab460d6 - fix(http): truncate streaming responses to content length (#36496)

Commit
74 days ago
fix(http): truncate streaming responses to content length (#36496) Fixes #36456 ## What - Truncate streaming Deno.serve response chunks to the remaining declared Content-Length. - Finish the fixed-length response and cancel the excess stream once that length is reached, including zero-length responses. - Cover both the normal and shared HTTP/1 response writers. - Verify that truncated fixed-length responses do not corrupt a reused HTTP/1 connection. ## Why The Deno-owned HTTP/1 path rejected an oversized stream chunk before writing any of it. When the first stream chunk exceeded Content-Length, clients received the response head but zero body bytes. This restores the pre-2.8.3 behavior by writing the valid prefix up to the declared length. ## Validation - ./tools/format.js --check ext/http/http_next.rs tests/unit/serve_test.ts - deno lint tests/unit/serve_test.ts - CARGO_INCREMENTAL=0 cargo clippy -j 2 -p deno_http -F deno_core/quickjs --lib -- -D warnings - CARGO_INCREMENTAL=0 cargo test -j 2 -p deno_http -F deno_core/quickjs --lib (45 passed) - CARGO_INCREMENTAL=0 cargo test -j 2 -p deno_http_h1 --lib (83 passed)
Author
Parents
Loading