From d93148130229afa6508794bbc2ff59ee0946ff2c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 19 Nov 2009 15:29:37 +0100 Subject: [PATCH] fix bug, first scan works. --- http_parser.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/http_parser.c b/http_parser.c index 6b0a94d..fc481fc 100644 --- a/http_parser.c +++ b/http_parser.c @@ -20,6 +20,12 @@ do { \ } while (0) #define CALLBACK(FOR) \ +do { \ + if (0 != FOR##_callback(parser, p)) return (p - data); \ + parser->FOR##_mark = NULL; \ +} while (0) + +#define CALLBACK_NOCLEAR(FOR) \ do { \ if (0 != FOR##_callback(parser, p)) return (p - data); \ } while (0) @@ -59,7 +65,6 @@ static inline int FOR##_callback (http_parser *parser, const char *p) \ if (parser->FOR##_size > MAX_FIELD_SIZE) return -1; \ int r = 0; \ if (parser->on_##FOR) r = parser->on_##FOR(parser, mark, p - mark); \ - parser->FOR##_mark = NULL; \ return r; \ } @@ -1191,12 +1196,12 @@ size_t http_parser_execute (http_parser *parser, const char *data, size_t len) } } - CALLBACK(header_field); - CALLBACK(header_value); - CALLBACK(fragment); - CALLBACK(query_string); - CALLBACK(path); - CALLBACK(uri); + CALLBACK_NOCLEAR(header_field); + CALLBACK_NOCLEAR(header_value); + CALLBACK_NOCLEAR(fragment); + CALLBACK_NOCLEAR(query_string); + CALLBACK_NOCLEAR(path); + CALLBACK_NOCLEAR(uri); parser->state = state; parser->header_state = header_state;