remove body_read

This saves space in the structure (it is now 28 bytes on x86), and
makes the handling of content_length more consistent between chunked
encoding and non-chunked-encoding.
event_stream
Cliff Frey 15 years ago committed by Ryan Dahl
parent 2d16d50425
commit 546f43a782

@ -1379,7 +1379,6 @@ size_t http_parser_execute (http_parser *parser,
break; break;
} }
parser->body_read = 0;
nread = 0; nread = 0;
if (parser->flags & F_UPGRADE) parser->upgrade = 1; if (parser->flags & F_UPGRADE) parser->upgrade = 1;
@ -1440,12 +1439,12 @@ size_t http_parser_execute (http_parser *parser,
} }
case s_body_identity: case s_body_identity:
to_read = MIN(pe - p, (ssize_t)(parser->content_length - parser->body_read)); to_read = MIN(pe - p, (ssize_t)parser->content_length);
if (to_read > 0) { 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; p += to_read - 1;
parser->body_read += to_read; parser->content_length -= to_read;
if (parser->body_read == parser->content_length) { if (parser->content_length == 0) {
CALLBACK2(message_complete); CALLBACK2(message_complete);
state = NEW_MESSAGE(); state = NEW_MESSAGE();
} }
@ -1458,7 +1457,6 @@ size_t http_parser_execute (http_parser *parser,
if (to_read > 0) { 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; p += to_read - 1;
parser->body_read += to_read;
} }
break; break;

@ -102,7 +102,6 @@ struct http_parser {
char flags; char flags;
size_t nread; size_t nread;
ssize_t body_read;
ssize_t content_length; ssize_t content_length;
/** READ-ONLY **/ /** READ-ONLY **/

Loading…
Cancel
Save