From de4f83ca3b9c15e09ba1b564abe06b8b3d5b4f77 Mon Sep 17 00:00:00 2001 From: Shenghao Zhang <3068863558@qq.com> Date: Sat, 5 Dec 2026 14:43:54 +0800 Subject: [PATCH] fix: route lenient bare-LF request version to headers_start --- src/llhttp/http.ts | 2 +- test/request/sample.md | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts index 981d30f1..e6f0af46 100644 --- a/src/llhttp/http.ts +++ b/src/llhttp/http.ts @@ -534,7 +534,7 @@ export class HTTP { .match( '\n', checkIfAllowLFWithoutCR( - n('req_http_complete_crlf'), + n('headers_start'), p.error(ERROR.INVALID_VERSION, 'Expected CRLF after version'), ), ) diff --git a/test/request/sample.md b/test/request/sample.md index 39f81f28..b43a7112 100644 --- a/test/request/sample.md +++ b/test/request/sample.md @@ -461,6 +461,32 @@ off=25 len=3 span[header_value]="abc" off=28 error code=25 reason="Missing expected CR after header value" ``` +## Bare LF after HTTP version (lenient) + + + +```http +GET / HTTP/1.1\nHost: foo\r\n\r\n +``` + +```log +off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete +off=4 len=1 span[url]="/" +off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete +off=11 len=3 span[version]="1.1" +off=14 version complete +off=15 len=4 span[header_field]="Host" +off=20 header_field complete +off=21 len=3 span[header_value]="foo" +off=26 header_value complete +off=28 headers complete method=1 v=1/1 flags=0 content_length=0 +off=28 message complete +``` + ## No LF after CR