diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-03-22 09:00:24 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-03-22 09:00:43 -0700 |
commit | 54d4efd44b6a6d9ac4430012377a4c5064fec6c6 (patch) | |
tree | 2d1dd144802e349de60b8cdb618593fae900bf47 /deps/http_parser/http_parser.h | |
parent | 765f0cdece338fcc09e6c318379a953132053194 (diff) | |
download | node-new-54d4efd44b6a6d9ac4430012377a4c5064fec6c6.tar.gz |
Upgrade http-parser
Now at version 6f72c780f0a237a775150a9963bcdf5299685cde
Diffstat (limited to 'deps/http_parser/http_parser.h')
-rw-r--r-- | deps/http_parser/http_parser.h | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/deps/http_parser/http_parser.h b/deps/http_parser/http_parser.h index 7fb00840fe..5b648fa9f6 100644 --- a/deps/http_parser/http_parser.h +++ b/deps/http_parser/http_parser.h @@ -24,11 +24,10 @@ extern "C" { #endif -#ifdef _MSC_VER -# include <stddef.h> -#endif + #include <sys/types.h> + /* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run * faster */ @@ -38,12 +37,16 @@ extern "C" { # define HTTP_PARSER_STRICT 0 #endif + /* Maximium header size allowed */ #define HTTP_MAX_HEADER_SIZE (80*1024) + typedef struct http_parser http_parser; +typedef struct http_parser_settings http_parser_settings; -/* Callbacks should return non-zero to indicate an error. The parse will + +/* Callbacks should return non-zero to indicate an error. The parser will * then halt execution. * * http_data_cb does not return data chunks. It will be call arbitrarally @@ -53,9 +56,11 @@ typedef struct http_parser http_parser; typedef int (*http_data_cb) (http_parser*, const char *at, size_t length); typedef int (*http_cb) (http_parser*); + /* Should be at least one longer than the longest request method */ #define HTTP_PARSER_MAX_METHOD_LEN 10 + /* Request Methods */ enum http_method { HTTP_DELETE = 0x0001 @@ -77,8 +82,10 @@ enum http_method , HTTP_UNLOCK = 0x4000 }; + enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE }; + struct http_parser { /** PRIVATE **/ enum http_parser_type type; @@ -114,17 +121,15 @@ struct http_parser { /** PUBLIC **/ void *data; /* A pointer to get hook to the "connection" or "socket" object */ +}; - /* an ordered list of callbacks */ +struct http_parser_settings { http_cb on_message_begin; - - /* requests only */ http_data_cb on_path; http_data_cb on_query_string; http_data_cb on_url; http_data_cb on_fragment; - http_data_cb on_header_field; http_data_cb on_header_value; http_cb on_headers_complete; @@ -132,15 +137,25 @@ struct http_parser { http_cb on_message_complete; }; + void http_parser_init(http_parser *parser, enum http_parser_type type); -size_t http_parser_execute(http_parser *parser, const char *data, size_t len); -/* Call this in the on_headers_complete or on_message_complete callback to - * determine if this will be the last message on the connection. - * If you are the server, respond with the "Connection: close" header - * if you are the client, close the connection. + + +size_t http_parser_execute(http_parser *parser, + http_parser_settings settings, + const char *data, + size_t len); + + +/* If http_should_keep_alive() in the on_headers_complete or + * on_message_complete callback returns true, then this will be should be + * the last message on the connection. + * If you are the server, respond with the "Connection: close" header. + * If you are the client, close the connection. */ int http_should_keep_alive(http_parser *parser); + #ifdef __cplusplus } #endif |