Skip to content

Commit

Permalink
Add test for empty header token.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenballus committed Oct 24, 2023
1 parent cf6fcfe commit 1d44bb9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/llhttp/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
21 changes: 21 additions & 0 deletions test/request/invalid.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,27 @@ off=14 version complete
off=19 error code=10 reason="Invalid header token"
```

### Invalid header token #3

<!-- meta={"type": "request", "noScan": true} -->
```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

<!-- meta={"type": "request"} -->
Expand Down

0 comments on commit 1d44bb9

Please sign in to comment.