File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -331,10 +331,20 @@ size_t http_parser_execute (http_parser *parser,
331
331
uint64_t nread = parser -> nread ;
332
332
333
333
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
336
347
}
337
- return 0 ;
338
348
}
339
349
340
350
/* 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,
1384
1394
break ;
1385
1395
1386
1396
default :
1397
+ parser -> state = state ;
1387
1398
return p - data ; /* Error */
1388
1399
}
1389
1400
}
Original file line number Diff line number Diff line change @@ -1735,14 +1735,22 @@ main (void)
1735
1735
1736
1736
/// REQUESTS
1737
1737
1738
-
1739
1738
test_simple ("hello world" , 0 );
1740
1739
test_simple ("GET / HTP/1.1\r\n\r\n" , 0 );
1741
1740
1741
+
1742
1742
test_simple ("ASDF / HTTP/1.1\r\n\r\n" , 0 );
1743
1743
test_simple ("PROPPATCHA / HTTP/1.1\r\n\r\n" , 0 );
1744
1744
test_simple ("GETA / HTTP/1.1\r\n\r\n" , 0 );
1745
1745
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
+
1746
1754
static const char * all_methods [] = {
1747
1755
"DELETE" ,
1748
1756
"GET" ,
You can’t perform that action at this time.
0 commit comments