From 1d44bb9957faab49262c8736afb16966b995cd6b Mon Sep 17 00:00:00 2001 From: Ben Kallus Date: Tue, 24 Oct 2023 11:10:35 -0400 Subject: [PATCH] Add test for empty header token. --- src/llhttp/http.ts | 2 +- test/request/invalid.md | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts index ac16453a..6a201ffe 100644 --- a/src/llhttp/http.ts +++ b/src/llhttp/http.ts @@ -542,7 +542,7 @@ export class HTTP { }).otherwise(this.headersCompleted()), }, onInvalidHeaderFieldChar), ) - .peek(':', p.error(ERROR.INVALID_HEADER_TOKEN, 'Empty header field')) + .peek(':', p.error(ERROR.INVALID_HEADER_TOKEN, 'Invalid header token')) .otherwise(span.headerField.start(n('header_field'))); n('header_field') diff --git a/test/request/invalid.md b/test/request/invalid.md index 8eadacf8..9fb83836 100644 --- a/test/request/invalid.md +++ b/test/request/invalid.md @@ -307,6 +307,27 @@ off=14 version complete off=19 error code=10 reason="Invalid header token" ``` +### Invalid header token #3 + + +```http +GET / HTTP/1.1 +: Bar + + +``` + +```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=11 len=3 span[version]="1.1" +off=14 version complete +off=16 error code=10 reason="Invalid header token" +``` + ### Invalid method