This repository was archived by the owner on Nov 6, 2022. It is now read-only.
http_parser: skip lws/rws in header field#295
Open
indutny wants to merge 1 commit intonodejs:mainfrom
Open
Conversation
Skip whitespace from the left and the right sides of the header field. See: nodejs/node#5844
Member
|
@indutny ... this is not working as expected. To test it, I added the following test case to test.c: diff --git a/test.c b/test.c
index 7b01dc3..dac6997 100644
--- a/test.c
+++ b/test.c
@@ -1153,6 +1153,28 @@ const struct message requests[] =
,.body= ""
}
+#if !HTTP_PARSER_STRICT
+#define WHITESPACE_IN_HEADER 42
+, {.name = "whitespace in header"
+ ,.type= HTTP_REQUEST
+ ,.raw= "GET /foo HTTP/1.1\r\n"
+ "XYZ : example.com\r\n"
+ "\r\n"
+ ,.should_keep_alive= TRUE
+ ,.message_complete_on_eof= FALSE
+ ,.http_major= 1
+ ,.http_minor= 1
+ ,.method= HTTP_GET
+ ,.request_path= "/foo"
+ ,.request_url= "/foo"
+ ,.query_string= ""
+ ,.fragment= ""
+ ,.num_headers= 1
+ ,.headers= { { "XYZ", "example.com" } }
+ ,.body= ""
+ }
+#endif
+
, {.name= NULL } /* sentinel */
};
Running bash-3.2$ make
./test_g
http_parser v2.6.2 (0x020602)
sizeof(http_parser) = 32
response scan 1/2 100%
response scan 2/2 100%
responses okay
request scan 1/4 100%
request scan 2/4 100%
request scan 3/4 100%
request scan 4/4 100%
requests okay
./test_fast
http_parser v2.6.2 (0x020602)
sizeof(http_parser) = 32
response scan 1/2 100%
response scan 2/2 100%
responses okay
*** Error: header field in 'whitespace in header' ***
expected 'XYZ'
found 'XYZ : example.com
'
make: *** [test] Abort trap: 6
bash-3.2$ Note the value for |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Skip whitespace from the left and the right sides of the header field.
See: nodejs/node#5844
cc @jasnell