-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: fix
llhttp_finish
semantics and add tests
Although implemented in a compatible way `llhttp_finish()` was never properly tested until now. Unsurprisingly, there was an incorrect behavior hidden in there. Fix: #25 PR-URL: #26 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
- Loading branch information
Showing
8 changed files
with
553 additions
and
47 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Finish | ||
====== | ||
|
||
Those tests check the return codes and the behavior of `llhttp_finish()` C API. | ||
|
||
## It should be safe to finish after GET request | ||
|
||
<!-- meta={"type": "request-finish"} --> | ||
```http | ||
GET / HTTP/1.1 | ||
``` | ||
|
||
```log | ||
off=0 message begin | ||
off=4 len=1 span[url]="/" | ||
off=18 headers complete method=1 v=1/1 flags=0 content_length=0 | ||
off=18 message complete | ||
off=NULL finish=0 | ||
``` | ||
|
||
## It should be unsafe to finish after incomplete PUT request | ||
|
||
<!-- meta={"type": "request-finish"} --> | ||
```http | ||
PUT / HTTP/1.1 | ||
Content-Length: 100 | ||
``` | ||
|
||
```log | ||
off=0 message begin | ||
off=4 len=1 span[url]="/" | ||
off=16 len=14 span[header_field]="Content-Length" | ||
off=32 len=3 span[header_value]="100" | ||
off=NULL finish=2 | ||
``` | ||
|
||
## It should be unsafe to finish inside of the header | ||
|
||
<!-- meta={"type": "request-finish"} --> | ||
```http | ||
PUT / HTTP/1.1 | ||
Content-Leng | ||
``` | ||
|
||
```log | ||
off=0 message begin | ||
off=4 len=1 span[url]="/" | ||
off=16 len=12 span[header_field]="Content-Leng" | ||
off=NULL finish=2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Finish | ||
====== | ||
|
||
Those tests check the return codes and the behavior of `llhttp_finish()` C API. | ||
|
||
## It should be safe to finish with cb after empty response | ||
|
||
<!-- meta={"type": "response-finish"} --> | ||
```http | ||
HTTP/1.1 200 OK | ||
``` | ||
|
||
```log | ||
off=0 message begin | ||
off=13 len=2 span[status]="OK" | ||
off=19 headers complete status=200 v=1/1 flags=0 content_length=0 | ||
off=NULL finish=1 | ||
``` |