From 8732d108a4ca0b4ee1b42cc1fab4a727ee300ecc Mon Sep 17 00:00:00 2001 From: Cliff Frey Date: Fri, 28 May 2010 01:43:50 -0700 Subject: [PATCH] stop tracking lengths of returned values This drops support for MAX_FIELD_SIZE, and saves 4 more bytes in the parser object (44 bytes total now). --- http_parser.c | 24 ++++++------------------ http_parser.h | 2 -- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/http_parser.c b/http_parser.c index 6f3e1d7..1b070c7 100644 --- a/http_parser.c +++ b/http_parser.c @@ -32,9 +32,6 @@ #endif -#define MAX_FIELD_SIZE (80*1024) - - #define CALLBACK2(FOR) \ do { \ if (settings->on_##FOR) { \ @@ -46,20 +43,11 @@ do { \ #define MARK(FOR) \ do { \ FOR##_mark = p; \ - parser->current_mark_size = 0; \ } while (0) -#define MARK_NOSIZECLEAR(FOR) \ -do { \ - FOR##_mark = p; \ -} while (0) - - #define CALLBACK_NOCLEAR(FOR) \ do { \ if (FOR##_mark) { \ - parser->current_mark_size += p - FOR##_mark; \ - if (parser->current_mark_size > MAX_FIELD_SIZE) return (p - data); \ if (settings->on_##FOR) { \ if (0 != settings->on_##FOR(parser, \ FOR##_mark, \ @@ -674,7 +662,7 @@ size_t http_parser_execute (http_parser *parser, if (ch == '/') { MARK(url); - MARK_NOSIZECLEAR(path); + MARK(path); state = s_req_path; break; } @@ -724,7 +712,7 @@ size_t http_parser_execute (http_parser *parser, state = s_req_port; break; case '/': - MARK_NOSIZECLEAR(path); + MARK(path); state = s_req_path; break; case ' ': @@ -746,7 +734,7 @@ size_t http_parser_execute (http_parser *parser, if (ch >= '0' && ch <= '9') break; switch (ch) { case '/': - MARK_NOSIZECLEAR(path); + MARK(path); state = s_req_path; break; case ' ': @@ -802,7 +790,7 @@ size_t http_parser_execute (http_parser *parser, case s_req_query_string_start: { if (USUAL(ch)) { - MARK_NOSIZECLEAR(query_string); + MARK(query_string); state = s_req_query_string; break; } @@ -871,7 +859,7 @@ size_t http_parser_execute (http_parser *parser, case s_req_fragment_start: { if (USUAL(ch)) { - MARK_NOSIZECLEAR(fragment); + MARK(fragment); state = s_req_fragment; break; } @@ -892,7 +880,7 @@ size_t http_parser_execute (http_parser *parser, state = s_header_field_start; break; case '?': - MARK_NOSIZECLEAR(fragment); + MARK(fragment); state = s_req_fragment; break; case '#': diff --git a/http_parser.h b/http_parser.h index a3c707e..a4abf32 100644 --- a/http_parser.h +++ b/http_parser.h @@ -105,8 +105,6 @@ struct http_parser { ssize_t body_read; ssize_t content_length; - size_t current_mark_size; - /** READ-ONLY **/ unsigned short status_code; /* responses only */ unsigned short method; /* requests only */