From a59ba4d866ef6abfa25e3f763e6c4f8990a4877d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 26 Jul 2010 14:59:39 -0700 Subject: [PATCH] Support long messages --- http_parser.c | 10 +++++----- http_parser.h | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/http_parser.c b/http_parser.c index 9a340fc..ac1b9d6 100644 --- a/http_parser.c +++ b/http_parser.c @@ -287,12 +287,12 @@ size_t http_parser_execute (http_parser *parser, { char c, ch; const char *p = data, *pe; - ssize_t to_read; + int64_t to_read; enum state state = (enum state) parser->state; enum header_states header_state = (enum header_states) parser->header_state; - size_t index = parser->index; - size_t nread = parser->nread; + uint64_t index = parser->index; + uint64_t nread = parser->nread; if (len == 0) { if (state == s_body_identity_eof) { @@ -1376,7 +1376,7 @@ size_t http_parser_execute (http_parser *parser, } case s_body_identity: - to_read = MIN(pe - p, (ssize_t)parser->content_length); + to_read = MIN(pe - p, (int64_t)parser->content_length); if (to_read > 0) { if (settings->on_body) settings->on_body(parser, p, to_read); p += to_read - 1; @@ -1461,7 +1461,7 @@ size_t http_parser_execute (http_parser *parser, { assert(parser->flags & F_CHUNKED); - to_read = MIN(pe - p, (ssize_t)(parser->content_length)); + to_read = MIN(pe - p, (int64_t)(parser->content_length)); if (to_read > 0) { if (settings->on_body) settings->on_body(parser, p, to_read); diff --git a/http_parser.h b/http_parser.h index f019985..2e395a2 100644 --- a/http_parser.h +++ b/http_parser.h @@ -26,6 +26,7 @@ extern "C" { #include +#include #ifdef _WIN32 typedef unsigned int size_t; @@ -106,8 +107,8 @@ struct http_parser { char flags; - size_t nread; - ssize_t content_length; + uint64_t nread; + int64_t content_length; /** READ-ONLY **/ unsigned short http_major;