Skip to content
Merged
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 @@ -422,7 +422,7 @@ export class HTTP {
.skipTo(n('res_status'));

n('res_line_almost_done')
.match([ '\r', '\n' ], onStatusComplete)
.match('\n', onStatusComplete)
.otherwise(this.testLenientFlags(LENIENT_FLAGS.OPTIONAL_LF_AFTER_CR, {
1: onStatusComplete,
}, p.error(ERROR.STRICT, 'Expected LF after CR')));
Expand Down
65 changes: 64 additions & 1 deletion test/response/invalid.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,69 @@ off=22 len=1 span[header_value]="1"
off=24 error code=3 reason="Missing expected LF after header value"
```

### Bare CR after response line

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


```

```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=16 error code=2 reason="Expected LF after CR"
```

### Bare CR after response line (lenient)

<!-- meta={"type": "response-lenient-optional-lf-after-cr"} -->
```http
HTTP/1.1 200 OK\rContent-Length: 0


```

```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=16 status complete
off=16 len=14 span[header_field]="Content-Length"
off=31 header_field complete
off=32 len=1 span[header_value]="0"
off=35 header_value complete
off=37 headers complete status=200 v=1/1 flags=20 content_length=0
off=37 message complete
```

### Bare CR followed by CR after response line

<!-- meta={"type": "response"} -->
```http
HTTP/1.1 200 OK\r\rContent-Length: 4

Evil
```

```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=16 error code=2 reason="Expected LF after CR"
```

### Invalid HTTP version

<!-- meta={"type": "response"} -->
Expand Down Expand Up @@ -313,4 +376,4 @@ off=35 headers complete status=200 v=1/1 flags=0 content_length=0
off=35 len=4 span[body]="BODY"
off=39 len=1 span[body]=lf
off=40 len=1 span[body]="\"
```
```
Loading