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

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

Loading…
Cancel
Save