Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix multiple begin message cbs when response starts with CR/LF #432

Merged
merged 2 commits into from Jul 19, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+4 −4
Diff settings

Always

Just for now

@@ -758,6 +758,8 @@ size_t http_parser_execute (http_parser *parser,

case s_start_res:
{
if (ch == CR || ch == LF)
break;
parser->flags = 0;
parser->content_length = ULLONG_MAX;

@@ -766,10 +768,6 @@ size_t http_parser_execute (http_parser *parser,
UPDATE_STATE(s_res_H);
break;

case CR:
case LF:
break;

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Jun 15, 2018

Member

Now that the switch has only one case (well, two if you count the default) can you turn it into an if statement?

default:
SET_ERRNO(HPE_INVALID_CONSTANT);
goto error;
2 test.c
@@ -2094,6 +2094,7 @@ int
message_begin_cb (http_parser *p)
{
assert(p == &parser);
assert(!messages[num_messages].message_begin_cb_called);
messages[num_messages].message_begin_cb_called = TRUE;
return 0;
}
@@ -4189,6 +4190,7 @@ main (void)
test_simple_type("HTTP/11.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
test_simple_type("HTTP/1.01 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
test_simple_type("HTTP/1.1\t200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);
test_simple_type("\rHTTP/1.1\t200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE);

for (i = 0; i < ARRAY_SIZE(responses); i++) {
test_message(&responses[i]);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.