uvicorn icon indicating copy to clipboard operation
uvicorn copied to clipboard

httptools: chunked response to HTTP/1.0 clients violates RFC 9112 section 6.1

Open Lushiyao5 opened this issue 2 weeks ago • 0 comments

For HTTP/1.0 clients, the httptools implementation unconditionally appends transfer-encoding: chunked and writes chunked bodies when the application response has no explicit content-length or transfer-encoding (streaming responses). RFC 9112 section 6.1 requires a server MUST NOT send chunked to a client whose HTTP version is 1.0. The h11 implementation in the same repository correctly falls back to close-delimited framing for the same input, so the two protocol implementations diverge for identical applications.

Reproduced on current main with a mocked transport: the HTTP/1.0 streaming response arrives with transfer-encoding: chunked and a chunked body on httptools, and unparsed with close framing on h11.

Ready fix branch (one-line header change + None guard for the length validation, plus a parameterized regression test that fails on the unfixed httptools path):

https://github.com/Lushiyao5/uvicorn/tree/fix/http10-not-chunked-20261115

Happy to open a PR if maintainers prefer - noting that PR creation appears limited to collaborators for this repository (the API returns 404 for create_pull_request).

Lushiyao5 avatar Nov 15 '26 16:11 Lushiyao5