diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2009-12-07 15:21:12 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2009-12-07 15:21:12 +0100 |
commit | ee8530e0ee386492ca519004cfaa34de650b17b3 (patch) | |
tree | aa0c156729fb28dd15643dbccb3cfb47e5c44671 /deps/http_parser | |
parent | 756544fd28d5e7156fe7d27adc3e0265268fd76d (diff) | |
download | android-node-v8-ee8530e0ee386492ca519004cfaa34de650b17b3.tar.gz android-node-v8-ee8530e0ee386492ca519004cfaa34de650b17b3.tar.bz2 android-node-v8-ee8530e0ee386492ca519004cfaa34de650b17b3.zip |
offload method look up to http-parser
Diffstat (limited to 'deps/http_parser')
-rw-r--r-- | deps/http_parser/http_parser.h | 53 | ||||
-rw-r--r-- | deps/http_parser/test.c | 5 |
2 files changed, 41 insertions, 17 deletions
diff --git a/deps/http_parser/http_parser.h b/deps/http_parser/http_parser.h index bd3123a918..9d14bbf5bf 100644 --- a/deps/http_parser/http_parser.h +++ b/deps/http_parser/http_parser.h @@ -55,22 +55,23 @@ typedef int (*http_cb) (http_parser*); /* Request Methods */ enum http_method - { HTTP_DELETE = 0x0002 - , HTTP_GET = 0x0004 - , HTTP_HEAD = 0x0008 - , HTTP_POST = 0x0010 - , HTTP_PUT = 0x0020 - /* webdav methods */ - , HTTP_COPY = 0x0040 - , HTTP_LOCK = 0x0080 - , HTTP_MKCOL = 0x0100 - , HTTP_MOVE = 0x0200 - , HTTP_OPTIONS = 0x0400 - , HTTP_PROPFIND = 0x0800 - , HTTP_PROPPATCH = 0x1000 - , HTTP_TRACE = 0x2000 + { HTTP_DELETE = 0x0001 + , HTTP_GET = 0x0002 + , HTTP_HEAD = 0x0004 + , HTTP_POST = 0x0008 + , HTTP_PUT = 0x0010 + /* pathological */ + , HTTP_CONNECT = 0x0020 + , HTTP_OPTIONS = 0x0040 + , HTTP_TRACE = 0x0080 + /* webdav */ + , HTTP_COPY = 0x0100 + , HTTP_LOCK = 0x0200 + , HTTP_MKCOL = 0x0400 + , HTTP_MOVE = 0x0800 + , HTTP_PROPFIND = 0x1000 + , HTTP_PROPPATCH = 0x2000 , HTTP_UNLOCK = 0x4000 - , HTTP_CONNECT = 0x8000 }; struct http_parser { @@ -134,6 +135,28 @@ size_t http_parse_responses(http_parser *parser, const char *data, size_t len); */ int http_should_keep_alive(http_parser *parser); +static inline const char * http_method_str (enum http_method method) +{ + switch (method) { + case HTTP_DELETE: return "DELETE"; + case HTTP_GET: return "GET"; + case HTTP_HEAD: return "HEAD"; + case HTTP_POST: return "POST"; + case HTTP_PUT: return "PUT"; + case HTTP_CONNECT: return "CONNECT"; + case HTTP_OPTIONS: return "OPTIONS"; + case HTTP_TRACE: return "TRACE"; + case HTTP_COPY: return "COPY"; + case HTTP_LOCK: return "LOCK"; + case HTTP_MKCOL: return "MKCOL"; + case HTTP_MOVE: return "MOVE"; + case HTTP_PROPFIND: return "PROPFIND"; + case HTTP_PROPPATCH: return "PROPPATCH"; + case HTTP_UNLOCK: return "UNLOCK"; + default: return (const char*)0; + } +} + #ifdef __cplusplus } #endif diff --git a/deps/http_parser/test.c b/deps/http_parser/test.c index b42ffd559b..f8cf268dc5 100644 --- a/deps/http_parser/test.c +++ b/deps/http_parser/test.c @@ -1049,10 +1049,12 @@ main (void) printf("sizeof(http_parser) = %d\n", sizeof(http_parser)); + assert(strcmp(http_method_str(HTTP_GET), "GET") == 0); + assert(strcmp(http_method_str(HTTP_CONNECT), "CONNECT") == 0); + for (request_count = 0; requests[request_count].name; request_count++); for (response_count = 0; responses[response_count].name; response_count++); -#if 0 //// RESPONSES for (i = 0; i < response_count; i++) { @@ -1076,7 +1078,6 @@ main (void) ); puts("responses okay"); -#endif /// REQUESTS |