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

* 现修正,每次调用HTTP解析函数后,无论是否到达消息边界,都检查是否上层是否构建了请求/应答。
This commit is contained in:
luqiuwen
2019-09-09 15:35:40 +08:00
committed by 陆秋文
parent f76720753c
commit 18be5ab07f
2 changed files with 11 additions and 21 deletions

View File

@@ -386,6 +386,7 @@ enum tfe_stream_action http_connection_entry(const struct tfe_stream * stream, e
bool __need_to_close_the_session = false; bool __need_to_close_the_session = false;
int ret = 0; int ret = 0;
int user_construct_ret = 0;
enum tfe_stream_action __action = ACTION_FORWARD_DATA; enum tfe_stream_action __action = ACTION_FORWARD_DATA;
size_t __action_args = 0; size_t __action_args = 0;
@@ -454,6 +455,16 @@ enum tfe_stream_action http_connection_entry(const struct tfe_stream * stream, e
goto __passthrough; goto __passthrough;
} }
user_construct_ret = (dir == CONN_DIR_DOWNSTREAM) ?
__on_request_handle_user_req_or_resp(stream, hs_private, hf_private_in, __need_to_close_the_session) :
__on_response_handle_user_req_or_resp(stream, hs_private, hf_private_in, __need_to_close_the_session);
if (user_construct_ret < 0)
{
assert(0);
goto __passthrough;
}
/* Need more data, no boundary touched */ /* Need more data, no boundary touched */
if (ret == 0) if (ret == 0)
{ {
@@ -477,16 +488,6 @@ enum tfe_stream_action http_connection_entry(const struct tfe_stream * stream, e
goto __passthrough; goto __passthrough;
} }
ret = (dir == CONN_DIR_DOWNSTREAM) ?
__on_request_handle_user_req_or_resp(stream, hs_private, hf_private_in, __need_to_close_the_session) :
__on_response_handle_user_req_or_resp(stream, hs_private, hf_private_in, __need_to_close_the_session);
if (ret < 0)
{
assert(0);
goto __passthrough;
}
/* Touch a boundary, such as the end of HTTP headers, bodys, et al. */ /* Touch a boundary, such as the end of HTTP headers, bodys, et al. */
__action_args = hf_private_in->parse_cursor; __action_args = hf_private_in->parse_cursor;
hf_private_in->parse_cursor = 0; hf_private_in->parse_cursor = 0;

View File

@@ -377,17 +377,6 @@ static int __parser_callback_on_headers_complete(http_parser * parser)
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;
} }