add http_parser_should_keep_alive()

version0.2
Ryan 16 years ago
parent d1d91be27b
commit 7898f1a97a

@ -121,7 +121,7 @@ size_t http_parser_execute (http_parser *parser, const char *data, size_t len);
int http_parser_has_error (http_parser *parser); int http_parser_has_error (http_parser *parser);
int http_message_should_keep_alive (http_parser *message); int http_parser_should_keep_alive (http_parser *parser);
#define http_message_has_body(parser) \ #define http_message_has_body(parser) \
(parser->transfer_encoding == HTTP_CHUNKED || parser->content_length > 0 ) (parser->transfer_encoding == HTTP_CHUNKED || parser->content_length > 0 )

@ -65,7 +65,7 @@ static int unhex[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
parser->version_major = 0; \ parser->version_major = 0; \
parser->version_minor = 0; \ parser->version_minor = 0; \
parser->number_of_headers = 0; \ parser->number_of_headers = 0; \
parser->keep_alive = 0; \ parser->keep_alive = -1; \
parser->content_length = 0; \ parser->content_length = 0; \
parser->body_read = 0; parser->body_read = 0;
@ -146,16 +146,18 @@ do { \
} }
action headers_complete { action headers_complete {
if(parser->on_headers_complete) if(parser->on_headers_complete) {
callback_return_value = parser->on_headers_complete(parser); callback_return_value = parser->on_headers_complete(parser);
if (callback_return_value != 0) fbreak; if (callback_return_value != 0) fbreak;
} }
}
action begin_message { action begin_message {
if(parser->on_message_begin) if(parser->on_message_begin) {
callback_return_value = parser->on_message_begin(parser); callback_return_value = parser->on_message_begin(parser);
if (callback_return_value != 0) fbreak; if (callback_return_value != 0) fbreak;
} }
}
action content_length { action content_length {
parser->content_length *= 10; parser->content_length *= 10;
@ -401,18 +403,16 @@ http_parser_has_error (http_parser *parser)
return parser->cs == http_parser_error; return parser->cs == http_parser_error;
} }
#if 0
int int
http_should_keep_alive (http *request) http_parser_should_keep_alive (http_parser *parser)
{ {
if (request->keep_alive == -1) if (parser->keep_alive == -1)
if (request->version_major == 1) if (parser->version_major == 1)
return (request->version_minor != 0); return (parser->version_minor != 0);
else if (request->version_major == 0) else if (parser->version_major == 0)
return FALSE; return FALSE;
else else
return TRUE; return TRUE;
else else
return request->keep_alive; return parser->keep_alive;
} }
#endif

Loading…
Cancel
Save