Skip to content

Commit 3abebfe

Browse files
committed
Upgrade http-parser to nodejs/http-parser@2498961
1 parent 38c49fb commit 3abebfe

6 files changed

Lines changed: 81 additions & 23 deletions

File tree

deps/http_parser/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ tags
33
test
44
test_g
55
test_fast
6-
http_parser.Makefile
7-
http_parser.target.mk
8-
test.target.mk

deps/http_parser/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

deps/http_parser/http_parser.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,13 @@ size_t http_parser_execute (http_parser *parser,
370370
uint64_t index = parser->index;
371371
uint64_t nread = parser->nread;
372372

373+
/* technically we could combine all of these (except for url_mark) into one
374+
variable, saving stack space, but it seems more clear to have them
375+
separated. */
376+
const char *header_field_mark = 0;
377+
const char *header_value_mark = 0;
378+
const char *url_mark = 0;
379+
373380
/* We're in an error state. Don't bother doing anything. */
374381
if (HTTP_PARSER_ERRNO(parser) != HPE_OK) {
375382
return 0;
@@ -396,12 +403,6 @@ size_t http_parser_execute (http_parser *parser,
396403
}
397404
}
398405

399-
/* technically we could combine all of these (except for url_mark) into one
400-
variable, saving stack space, but it seems more clear to have them
401-
separated. */
402-
const char *header_field_mark = 0;
403-
const char *header_value_mark = 0;
404-
const char *url_mark = 0;
405406

406407
if (state == s_header_field)
407408
header_field_mark = data;
@@ -514,7 +515,7 @@ size_t http_parser_execute (http_parser *parser,
514515
break;
515516

516517
case s_res_first_http_major:
517-
if (ch < '1' || ch > '9') {
518+
if (ch < '0' || ch > '9') {
518519
SET_ERRNO(HPE_INVALID_VERSION);
519520
goto error;
520521
}
@@ -690,12 +691,13 @@ size_t http_parser_execute (http_parser *parser,
690691

691692
case s_req_method:
692693
{
694+
const char *matcher;
693695
if (ch == '\0') {
694696
SET_ERRNO(HPE_INVALID_METHOD);
695697
goto error;
696698
}
697699

698-
const char *matcher = method_strings[parser->method];
700+
matcher = method_strings[parser->method];
699701
if (ch == ' ' && matcher[index] == '\0') {
700702
state = s_req_spaces_before_url;
701703
} else if (ch == matcher[index]) {

deps/http_parser/http_parser.gyp

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,69 @@
55
# ./gyp/gyp -f make --depth=`pwd` http_parser.gyp
66
# ./out/Debug/test
77
{
8+
'target_defaults': {
9+
'default_configuration': 'Debug',
10+
'configurations': {
11+
# TODO: hoist these out and put them somewhere common, because
12+
# RuntimeLibrary MUST MATCH across the entire project
13+
'Debug': {
14+
'defines': [ 'DEBUG', '_DEBUG' ],
15+
'msvs_settings': {
16+
'VCCLCompilerTool': {
17+
'RuntimeLibrary': 1, # static debug
18+
},
19+
},
20+
},
21+
'Release': {
22+
'defines': [ 'NDEBUG' ],
23+
'msvs_settings': {
24+
'VCCLCompilerTool': {
25+
'RuntimeLibrary': 0, # static release
26+
},
27+
},
28+
}
29+
},
30+
'msvs_settings': {
31+
'VCCLCompilerTool': {
32+
},
33+
'VCLibrarianTool': {
34+
},
35+
'VCLinkerTool': {
36+
'GenerateDebugInformation': 'true',
37+
},
38+
},
39+
'conditions': [
40+
['OS == "win"', {
41+
'defines': [
42+
'WIN32'
43+
],
44+
}]
45+
],
46+
},
47+
848
'targets': [
949
{
1050
'target_name': 'http_parser',
11-
'type': '<(library)',
51+
'type': 'static_library',
1252
'include_dirs': [ '.' ],
1353
'direct_dependent_settings': {
1454
'include_dirs': [ '.' ],
1555
},
1656
'defines': [ 'HTTP_PARSER_STRICT=0' ],
1757
'sources': [ './http_parser.c', ],
18-
'msvs_settings': {
19-
'VCCLCompilerTool': {
20-
# Compile as C++. http_parser.c is actually C99, but C++ is
21-
# close enough in this case.
22-
'CompileAs': 2, # compile as C++
23-
},
24-
},
58+
'conditions': [
59+
['OS=="win"', {
60+
'msvs_settings': {
61+
'VCCLCompilerTool': {
62+
# Compile as C++. http_parser.c is actually C99, but C++ is
63+
# close enough in this case.
64+
'CompileAs': 2,
65+
},
66+
},
67+
}]
68+
],
2569
},
70+
2671
{
2772
'target_name': 'test',
2873
'type': 'executable',

deps/http_parser/http_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ struct http_parser {
222222
* Should be checked when http_parser_execute() returns in addition to
223223
* error checking.
224224
*/
225-
char upgrade : 1;
225+
unsigned char upgrade : 1;
226226

227227
#if HTTP_PARSER_DEBUG
228228
uint32_t error_lineno;

deps/http_parser/test.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,24 @@ const struct message responses[] =
10411041
,.body= ""
10421042
}
10431043

1044-
1044+
#define HTTP_VERSION_0_9 12
1045+
/* Should handle HTTP/0.9 */
1046+
, {.name= "http version 0.9"
1047+
,.type= HTTP_RESPONSE
1048+
,.raw= "HTTP/0.9 200 OK\r\n"
1049+
"\r\n"
1050+
,.should_keep_alive= FALSE
1051+
,.message_complete_on_eof= TRUE
1052+
,.http_major= 0
1053+
,.http_minor= 9
1054+
,.status_code= 200
1055+
,.num_headers= 0
1056+
,.headers=
1057+
{}
1058+
,.body= ""
1059+
}
10451060
, {.name= NULL } /* sentinel */
1061+
10461062
};
10471063

10481064
int

0 commit comments

Comments
 (0)