Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/llhttp/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ export class HTTP {
.otherwise(n('header_value_content_length_ws'));

n('header_value_content_length_ws')
.match(' ', n('header_value_content_length_ws'))
.match([ ' ', '\t' ], n('header_value_content_length_ws'))
.peek([ '\r', '\n' ],
this.setFlag(FLAGS.CONTENT_LENGTH, 'header_value_otherwise'))
.otherwise(invalidContentLength('Invalid character in Content-Length'));
Expand Down
27 changes: 27 additions & 0 deletions test/request/content-length.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,33 @@ off=39 header_value complete
off=41 headers complete method=3 v=1/1 flags=20 content_length=42
```

### Tabs in `Content-Length` (surrounding)

<!-- meta={"type": "request"} -->
```http
POST / HTTP/1.1
Content-Length:\t42\t


```

```log
off=0 message begin
off=0 len=4 span[method]="POST"
off=4 method complete
off=5 len=1 span[url]="/"
off=7 url complete
off=7 len=4 span[protocol]="HTTP"
off=11 protocol complete
off=12 len=3 span[version]="1.1"
off=15 version complete
off=17 len=14 span[header_field]="Content-Length"
off=32 header_field complete
off=33 len=5 span[header_value]="42\t "
off=40 header_value complete
off=42 headers complete method=3 v=1/1 flags=20 content_length=42
```

### Spaces in `Content-Length` #2

<!-- meta={"type": "request"} -->
Expand Down
25 changes: 25 additions & 0 deletions test/response/content-length.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,28 @@ off=80 headers complete status=200 v=1/1 flags=20 content_length=456
off=80 skip body
off=80 message complete
```

## Tabs in `Content-Length` (surrounding)

<!-- meta={"type": "response"} -->
```http
HTTP/1.1 200 OK
Content-Length:\t42\t


```

```log
off=0 message begin
off=0 len=4 span[protocol]="HTTP"
off=4 protocol complete
off=5 len=3 span[version]="1.1"
off=8 version complete
off=13 len=2 span[status]="OK"
off=17 status complete
off=17 len=14 span[header_field]="Content-Length"
off=32 header_field complete
off=33 len=3 span[header_value]="42\t"
off=38 header_value complete
off=40 headers complete status=200 v=1/1 flags=20 content_length=42
```
Loading