diff --git a/README.md b/README.md index 6666482..fcc62f2 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ When data is received on the socket execute the parser and check for errors. * Note we pass the recved==0 to http_parse_requests to signal * that EOF has been recieved. */ - nparsed = http_parser_execute(parser, settings, buf, recved); + nparsed = http_parser_execute(parser, &settings, buf, recved); if (parser->upgrade) { /* handle new protocol */ diff --git a/http_parser.c b/http_parser.c index 7823dd0..e7133c5 100644 --- a/http_parser.c +++ b/http_parser.c @@ -37,8 +37,8 @@ #define CALLBACK2(FOR) \ do { \ - if (settings.on_##FOR) { \ - if (0 != settings.on_##FOR(parser)) return (p - data); \ + if (settings->on_##FOR) { \ + if (0 != settings->on_##FOR(parser)) return (p - data); \ } \ } while (0) @@ -55,8 +55,8 @@ do { \ if (parser->FOR##_mark) { \ parser->FOR##_size += p - parser->FOR##_mark; \ if (parser->FOR##_size > MAX_FIELD_SIZE) return (p - data); \ - if (settings.on_##FOR) { \ - if (0 != settings.on_##FOR(parser, \ + if (settings->on_##FOR) { \ + if (0 != settings->on_##FOR(parser, \ parser->FOR##_mark, \ p - parser->FOR##_mark)) \ { \ @@ -282,7 +282,7 @@ enum flags size_t http_parser_execute (http_parser *parser, - http_parser_settings settings, + const http_parser_settings *settings, const char *data, size_t len) { @@ -1364,7 +1364,7 @@ size_t http_parser_execute (http_parser *parser, case s_body_identity: to_read = MIN(pe - p, (ssize_t)(parser->content_length - parser->body_read)); if (to_read > 0) { - if (settings.on_body) settings.on_body(parser, p, to_read); + if (settings->on_body) settings->on_body(parser, p, to_read); p += to_read - 1; parser->body_read += to_read; if (parser->body_read == parser->content_length) { @@ -1378,7 +1378,7 @@ size_t http_parser_execute (http_parser *parser, case s_body_identity_eof: to_read = pe - p; if (to_read > 0) { - if (settings.on_body) settings.on_body(parser, p, to_read); + if (settings->on_body) settings->on_body(parser, p, to_read); p += to_read - 1; parser->body_read += to_read; } @@ -1451,7 +1451,7 @@ size_t http_parser_execute (http_parser *parser, to_read = MIN(pe - p, (ssize_t)(parser->content_length)); if (to_read > 0) { - if (settings.on_body) settings.on_body(parser, p, to_read); + if (settings->on_body) settings->on_body(parser, p, to_read); p += to_read - 1; } diff --git a/http_parser.h b/http_parser.h index f367872..e1f56e2 100644 --- a/http_parser.h +++ b/http_parser.h @@ -149,7 +149,7 @@ void http_parser_init(http_parser *parser, enum http_parser_type type); size_t http_parser_execute(http_parser *parser, - http_parser_settings settings, + const http_parser_settings *settings, const char *data, size_t len); diff --git a/test.c b/test.c index 9accabd..03a98ff 100644 --- a/test.c +++ b/test.c @@ -898,7 +898,7 @@ inline size_t parse (const char *buf, size_t len) { size_t nparsed; currently_parsing_eof = (len == 0); - nparsed = http_parser_execute(parser, settings, buf, len); + nparsed = http_parser_execute(parser, &settings, buf, len); return nparsed; } @@ -906,7 +906,7 @@ inline size_t parse_count_body (const char *buf, size_t len) { size_t nparsed; currently_parsing_eof = (len == 0); - nparsed = http_parser_execute(parser, settings_count_body, buf, len); + nparsed = http_parser_execute(parser, &settings_count_body, buf, len); return nparsed; }