Skip to content

fix: Makes SP after status code mandatory - #869

Open
Falci wants to merge 2 commits into
nodejs:mainfrom
Falci:main
Open

Falci wants to merge 2 commits into
nodejs:mainfrom
Falci:main

Conversation

@Falci

@Falci Falci commented Jun 25, 2026

Copy link
Copy Markdown

@ShogunPanda

Copy link
Copy Markdown
Contributor

Thanks!
It looks good to me.
Can you just also provide a lenient flag we can relate to the lenient mode in Node?

@ShogunPanda

Copy link
Copy Markdown
Contributor

Thanks for adding the flag! The API surface (LENIENT_FLAGS.OPTIONAL_SP_AFTER_STATUS, llhttp_set_lenient_optional_sp_after_status, README) looks good and fits well with Node's lenient mode.

However, the lenient path doesn't work for the case it's meant to cover:

  1. CR is not consumed. In src/llhttp/http.ts (around lines 396-404), when the flag is enabled any non-space character goes to res_line_almost_done without consuming the \r. That node expects the \n (the CR was already consumed by the old .match('\r', n('res_line_almost_done'))). So HTTP/1.1 301\r\n with the flag on still fails with Expected LF after CR, while a bare HTTP/1.1 301\n passes. In the lenient branch please keep the original matches: \r → res_line_almost_done, \n → checkIfAllowLFWithoutCR(...), otherwise error.

  2. Missing tests for the flag. test/fixtures/index.ts doesn't register a response-lenient-optional-sp-after-status type, and there is no markdown test using it. Please add one covering at least HTTP/1.1 301\r\n (and \n together with OPTIONAL_LF_AFTER_CR). The request-... init in test/fixtures/extra.c can be dropped, since this only applies to the status line.

Also, CI on the current head is failing; please rebase/push so it runs again.

This branch has not been deployed

No deployments
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.

Missing second space in status line not rejected

2 participants