Skip to content

fix(http1): recognize \n\r\n as a head terminator in the partial-read fast path - #4147

Open
nam2ee wants to merge 1 commit into
hyperium:masterfrom
nam2ee:fix-h1-lf-crlf-fast-path
Open

fix(http1): recognize \n\r\n as a head terminator in the partial-read fast path#4147
nam2ee wants to merge 1 commit into
hyperium:masterfrom
nam2ee:fix-h1-lf-crlf-fast-path

Conversation

@nam2ee

@nam2ee nam2ee commented Aug 9, 2026

Copy link
Copy Markdown

Closes #4145.

is_complete_fast recognizes \r\n\r\n and \n\n as head terminators but not \n\r\n, while the full parser (httparse) accepts all three. So a request whose head ends with \n\r\n parses fine when it arrives in a single read, but stalls when it arrives split across reads: the fast path never reports the head complete and the connection keeps waiting for more bytes.

This extends the \n branch to also accept a following \r\n, using the same panic-safe slicing idiom as the \r branch. Added the \n\r\n witness and the \n\r negative to test_is_complete_fast, plus a parse-level test documenting that the full parser accepts this terminator.

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/1: request with \n\r\n head terminator is accepted only when it arrives in a single read

1 participant