Upgrade http-parser to joyent/http-parser@2498961
authorRyan Dahl <ry@tinyclouds.org>
Tue, 22 Nov 2011 20:54:12 +0000 (12:54 -0800)
committerRyan Dahl <ry@tinyclouds.org>
Tue, 22 Nov 2011 20:56:01 +0000 (12:56 -0800)
deps/http_parser/.gitignore
deps/http_parser/CMakeLists.txt [deleted file]
deps/http_parser/http_parser.c
deps/http_parser/http_parser.gyp
deps/http_parser/http_parser.h
deps/http_parser/test.c

index 5597865..04b7a1f 100644 (file)
@@ -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 (file)
index 7dd9fd2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-include_directories (.)
-add_library (http_parser http_parser.c)
\ No newline at end of file
index e905747..bbeceb0 100644 (file)
@@ -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]) {
index bd45122..c6eada7 100644 (file)
@@ -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',
index 7d39520..76a61f2 100644 (file)
@@ -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;
index 7d95b0e..6af0e78 100644 (file)
@@ -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