增加HTTP解析层的REQ_END, RESP_END类型回调事件,增加HTTP POST类型的单元测试用例。
This commit is contained in:
@@ -268,7 +268,7 @@ static int __parser_callback_on_body(struct http_parser * parser, const char * a
|
||||
hf_private->event_cb(hf_private, ev_body_begin, NULL, parser->content_length, hf_private->event_cb_user);
|
||||
}
|
||||
|
||||
if (hf_private->event_cb)
|
||||
if (hf_private->event_cb && length != 0)
|
||||
{
|
||||
hf_private->event_cb(hf_private, ev_body_cont, (const unsigned char *) at, length, hf_private->event_cb_user);
|
||||
}
|
||||
@@ -281,20 +281,29 @@ static int __parser_callback_on_message_complete(http_parser * parser)
|
||||
{
|
||||
struct http_half_private * hf_private = __PARSER_TO_HF_PRIVATE(parser);
|
||||
enum tfe_http_direction hf_direction = hf_private->hf_public.direction;
|
||||
|
||||
enum tfe_http_event ev_message_end;
|
||||
enum tfe_http_event ev_body_end;
|
||||
|
||||
if (hf_direction == TFE_HTTP_REQUEST)
|
||||
{
|
||||
ev_message_end = EV_HTTP_REQ_END;
|
||||
ev_body_end = EV_HTTP_REQ_BODY_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
ev_message_end = EV_HTTP_RESP_END;
|
||||
ev_body_end = EV_HTTP_RESP_BODY_END;
|
||||
}
|
||||
|
||||
if (hf_private->event_cb && hf_private->body_status == STATUS_READING)
|
||||
{
|
||||
hf_private->event_cb(hf_private, ev_body_end, NULL, 0, hf_private->event_cb_user);
|
||||
}
|
||||
|
||||
if (hf_private->event_cb)
|
||||
{
|
||||
hf_private->event_cb(hf_private, ev_body_end, NULL, 0, hf_private->event_cb_user);
|
||||
hf_private->event_cb(hf_private, ev_message_end, NULL, 0, hf_private->event_cb_user);
|
||||
}
|
||||
|
||||
hf_private->body_status = STATUS_COMPLETE;
|
||||
|
||||
Reference in New Issue
Block a user