Browse Source

Upgrade http-parser to joyent/http-parser@2498961

v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
3abebfea98
  1. 3
      deps/http_parser/.gitignore
  2. 2
      deps/http_parser/CMakeLists.txt
  3. 18
      deps/http_parser/http_parser.c
  4. 61
      deps/http_parser/http_parser.gyp
  5. 2
      deps/http_parser/http_parser.h
  6. 18
      deps/http_parser/test.c

3
deps/http_parser/.gitignore

@ -3,6 +3,3 @@ tags
test
test_g
test_fast
http_parser.Makefile
http_parser.target.mk
test.target.mk

2
deps/http_parser/CMakeLists.txt

@ -1,2 +0,0 @@
include_directories (.)
add_library (http_parser http_parser.c)

18
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]) {

61
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',

2
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;

18
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

Loading…
Cancel
Save