From: Ryan Dahl Date: Tue, 22 Nov 2011 20:54:12 +0000 (-0800) Subject: Upgrade http-parser to joyent/http-parser@2498961 X-Git-Tag: v0.6.3~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3abebfea98b9a5b0e048106884c56f9162400ed4;p=platform%2Fupstream%2Fnodejs.git Upgrade http-parser to joyent/http-parser@2498961 --- diff --git a/deps/http_parser/.gitignore b/deps/http_parser/.gitignore index 5597865..04b7a1f 100644 --- a/deps/http_parser/.gitignore +++ b/deps/http_parser/.gitignore @@ -3,6 +3,3 @@ tags test test_g test_fast -http_parser.Makefile -http_parser.target.mk -test.target.mk diff --git a/deps/http_parser/CMakeLists.txt b/deps/http_parser/CMakeLists.txt deleted file mode 100644 index 7dd9fd2..0000000 --- a/deps/http_parser/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -include_directories (.) -add_library (http_parser http_parser.c) \ No newline at end of file diff --git a/deps/http_parser/http_parser.c b/deps/http_parser/http_parser.c index e905747..bbeceb0 100644 --- a/deps/http_parser/http_parser.c +++ b/deps/http_parser/http_parser.c @@ -370,6 +370,13 @@ size_t http_parser_execute (http_parser *parser, uint64_t index = parser->index; uint64_t nread = parser->nread; + /* technically we could combine all of these (except for url_mark) into one + variable, saving stack space, but it seems more clear to have them + separated. */ + const char *header_field_mark = 0; + const char *header_value_mark = 0; + const char *url_mark = 0; + /* We're in an error state. Don't bother doing anything. */ if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { return 0; @@ -396,12 +403,6 @@ size_t http_parser_execute (http_parser *parser, } } - /* technically we could combine all of these (except for url_mark) into one - variable, saving stack space, but it seems more clear to have them - separated. */ - const char *header_field_mark = 0; - const char *header_value_mark = 0; - const char *url_mark = 0; if (state == s_header_field) header_field_mark = data; @@ -514,7 +515,7 @@ size_t http_parser_execute (http_parser *parser, break; case s_res_first_http_major: - if (ch < '1' || ch > '9') { + if (ch < '0' || ch > '9') { SET_ERRNO(HPE_INVALID_VERSION); goto error; } @@ -690,12 +691,13 @@ size_t http_parser_execute (http_parser *parser, case s_req_method: { + const char *matcher; if (ch == '\0') { SET_ERRNO(HPE_INVALID_METHOD); goto error; } - const char *matcher = method_strings[parser->method]; + matcher = method_strings[parser->method]; if (ch == ' ' && matcher[index] == '\0') { state = s_req_spaces_before_url; } else if (ch == matcher[index]) { diff --git a/deps/http_parser/http_parser.gyp b/deps/http_parser/http_parser.gyp index bd45122..c6eada7 100644 --- a/deps/http_parser/http_parser.gyp +++ b/deps/http_parser/http_parser.gyp @@ -5,24 +5,69 @@ # ./gyp/gyp -f make --depth=`pwd` http_parser.gyp # ./out/Debug/test { + 'target_defaults': { + 'default_configuration': 'Debug', + 'configurations': { + # TODO: hoist these out and put them somewhere common, because + # RuntimeLibrary MUST MATCH across the entire project + 'Debug': { + 'defines': [ 'DEBUG', '_DEBUG' ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 1, # static debug + }, + }, + }, + 'Release': { + 'defines': [ 'NDEBUG' ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 0, # static release + }, + }, + } + }, + 'msvs_settings': { + 'VCCLCompilerTool': { + }, + 'VCLibrarianTool': { + }, + 'VCLinkerTool': { + 'GenerateDebugInformation': 'true', + }, + }, + 'conditions': [ + ['OS == "win"', { + 'defines': [ + 'WIN32' + ], + }] + ], + }, + 'targets': [ { 'target_name': 'http_parser', - 'type': '<(library)', + 'type': 'static_library', 'include_dirs': [ '.' ], 'direct_dependent_settings': { 'include_dirs': [ '.' ], }, 'defines': [ 'HTTP_PARSER_STRICT=0' ], 'sources': [ './http_parser.c', ], - 'msvs_settings': { - 'VCCLCompilerTool': { - # Compile as C++. http_parser.c is actually C99, but C++ is - # close enough in this case. - 'CompileAs': 2, # compile as C++ - }, - }, + 'conditions': [ + ['OS=="win"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + # Compile as C++. http_parser.c is actually C99, but C++ is + # close enough in this case. + 'CompileAs': 2, + }, + }, + }] + ], }, + { 'target_name': 'test', 'type': 'executable', diff --git a/deps/http_parser/http_parser.h b/deps/http_parser/http_parser.h index 7d39520..76a61f2 100644 --- a/deps/http_parser/http_parser.h +++ b/deps/http_parser/http_parser.h @@ -222,7 +222,7 @@ struct http_parser { * Should be checked when http_parser_execute() returns in addition to * error checking. */ - char upgrade : 1; + unsigned char upgrade : 1; #if HTTP_PARSER_DEBUG uint32_t error_lineno; diff --git a/deps/http_parser/test.c b/deps/http_parser/test.c index 7d95b0e..6af0e78 100644 --- a/deps/http_parser/test.c +++ b/deps/http_parser/test.c @@ -1041,8 +1041,24 @@ const struct message responses[] = ,.body= "" } - +#define HTTP_VERSION_0_9 12 +/* Should handle HTTP/0.9 */ +, {.name= "http version 0.9" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/0.9 200 OK\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= TRUE + ,.http_major= 0 + ,.http_minor= 9 + ,.status_code= 200 + ,.num_headers= 0 + ,.headers= + {} + ,.body= "" + } , {.name= NULL } /* sentinel */ + }; int