test
test_g
test_fast
-http_parser.Makefile
-http_parser.target.mk
-test.target.mk
+++ /dev/null
-include_directories (.)
-add_library (http_parser http_parser.c)
\ No newline at end of file
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;
}
}
- /* 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;
break;
case s_res_first_http_major:
- if (ch < '1' || ch > '9') {
+ if (ch < '0' || ch > '9') {
SET_ERRNO(HPE_INVALID_VERSION);
goto error;
}
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]) {
# ./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',
* 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;
,.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