Skip to content

Commit e42c74e

Browse files
committed
Upgrade http-parser
1 parent f99fc29 commit e42c74e

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

deps/http_parser/http_parser.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,20 @@ size_t http_parser_execute (http_parser *parser,
331331
uint64_t nread = parser->nread;
332332

333333
if (len == 0) {
334-
if (state == s_body_identity_eof) {
335-
CALLBACK2(message_complete);
334+
switch (state) {
335+
case s_body_identity_eof:
336+
CALLBACK2(message_complete);
337+
return 0;
338+
339+
case s_dead:
340+
case s_start_req_or_res:
341+
case s_start_res:
342+
case s_start_req:
343+
return 0;
344+
345+
default:
346+
return 1; // error
336347
}
337-
return 0;
338348
}
339349

340350
/* technically we could combine all of these (except for url_mark) into one
@@ -1384,6 +1394,7 @@ size_t http_parser_execute (http_parser *parser,
13841394
break;
13851395

13861396
default:
1397+
parser->state = state;
13871398
return p - data; /* Error */
13881399
}
13891400
}

deps/http_parser/test.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -1735,14 +1735,22 @@ main (void)
17351735

17361736
/// REQUESTS
17371737

1738-
17391738
test_simple("hello world", 0);
17401739
test_simple("GET / HTP/1.1\r\n\r\n", 0);
17411740

1741+
17421742
test_simple("ASDF / HTTP/1.1\r\n\r\n", 0);
17431743
test_simple("PROPPATCHA / HTTP/1.1\r\n\r\n", 0);
17441744
test_simple("GETA / HTTP/1.1\r\n\r\n", 0);
17451745

1746+
// Well-formed but incomplete
1747+
test_simple("GET / HTTP/1.1\r\n"
1748+
"Content-Type: text/plain\r\n"
1749+
"Content-Length: 6\r\n"
1750+
"\r\n"
1751+
"fooba",
1752+
0);
1753+
17461754
static const char *all_methods[] = {
17471755
"DELETE",
17481756
"GET",

0 commit comments

Comments
 (0)