New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "int http_body_is_final(const http_parser *parser)" method. #124

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@bog-dan-ro
Contributor

bog-dan-ro commented Aug 31, 2012

It's useful to check if the current chunk is the last one.

@bnoordhuis

View changes

http_parser.c Outdated
int
http_body_is_final(const struct http_parser *parser) {
return (parser->state ==s_message_done)?1:0;

This comment has been minimized.

@bnoordhuis

bnoordhuis Aug 31, 2012

Member

Non-idiomatic code, use return parser->state == s_message_done;

This comment has been minimized.

@bog-dan-ro

bog-dan-ro Aug 31, 2012

Contributor

Done

@bnoordhuis

View changes

http_parser.h Outdated
@@ -313,6 +313,9 @@ int http_parser_parse_url(const char *buf, size_t buflen,
/* Pause or un-pause the parser; a nonzero value pauses */
void http_parser_pause(http_parser *parser, int paused);
/* checks if this is the final chunk of the body */

This comment has been minimized.

@bnoordhuis

bnoordhuis Aug 31, 2012

Member

s/checks/Checks/ and add punctuation. (Yes, I'm a language/grammar Nazi).

This comment has been minimized.

@bog-dan-ro

bog-dan-ro Aug 31, 2012

Contributor

Done :)

@bnoordhuis

View changes

test.c Outdated
check_body_is_final (const http_parser *p)
{
if (messages[num_messages].body_is_final)
{

This comment has been minimized.

@bnoordhuis

bnoordhuis Aug 31, 2012

Member

Style: brace on the same line.

This comment has been minimized.

@bog-dan-ro

bog-dan-ro Aug 31, 2012

Contributor

Done.

@bnoordhuis

View changes

test.c Outdated
@@ -1501,6 +1518,16 @@ struct message {
assert(0);
abort();
}
if (messages[num_messages].body_size && http_body_is_final(p) && !messages[num_messages].body_is_final)

This comment has been minimized.

@bnoordhuis

bnoordhuis Aug 31, 2012

Member

Long line, wrap at 80 columns.

This comment has been minimized.

@bog-dan-ro

bog-dan-ro Aug 31, 2012

Contributor

Done.

@udp

This comment has been minimized.

Contributor

udp commented Aug 31, 2012

Maybe http_message_is_complete would be a clearer name than http_body_is_final?

@bnoordhuis

This comment has been minimized.

Member

bnoordhuis commented Aug 31, 2012

Some style issues but generally LGTM.

@bnoordhuis

This comment has been minimized.

Member

bnoordhuis commented Aug 31, 2012

Maybe http_message_is_complete would be a clearer name than http_body_is_final?

Yes, I can live with that.

Add "int http_body_is_final(const http_parser *parser)" method.
It's useful to check if the current chunk is the last one.

@bog-dan-ro bog-dan-ro closed this Aug 31, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment