修正HTTP解析层在上层设置请求/应答后,需要等待源站消息完整后才将上层构建的请求/应答发出的问题。

* 原实现在HTTP解析过程中,只在HTTP消息的边界返回http_entry中的流程,故只能在站消息完整后才执行发出上层的请求/应答;
* 现修正,在HTTP的解析过程中,发现上层设置了请求/应答,则在HTTP头部完整后执行PAUSE动作,触发上层请求/应答的发送流程。
This commit is contained in:
luqiuwen
2019-09-04 17:19:56 +08:00
committed by 陆秋文
parent cd67f0edb7
commit e40cd3ba7f

View File

@@ -371,13 +371,23 @@ static int __parser_callback_on_headers_complete(http_parser * parser)
* The request/response cannot be suspend once any bytes has been forwarded to upstream */ * The request/response cannot be suspend once any bytes has been forwarded to upstream */
assert(hf_private->stream_action == ACTION_DEFER_DATA); assert(hf_private->stream_action == ACTION_DEFER_DATA);
} }
/* Otherwise, forward the request/response */ /* Otherwise, forward the request/response */
else else
{ {
hf_private->stream_action = ACTION_FORWARD_DATA; hf_private->stream_action = ACTION_FORWARD_DATA;
} }
if (hs_private && hf_direction == TFE_HTTP_REQUEST && hs_private->hf_private_req_user != NULL)
{
http_parser_pause(parser, 1);
assert(hf_private->stream_action != ACTION_FORWARD_DATA);
}
else if (hs_private && hf_direction == TFE_HTTP_RESPONSE && hs_private->hf_private_resp_user != NULL)
{
http_parser_pause(parser, 1);
assert(hf_private->stream_action != ACTION_FORWARD_DATA);
}
return 0; return 0;
} }