summaryrefslogtreecommitdiff
path: root/plugin/protocol/http/src
diff options
context:
space:
mode:
authorluqiuwen <[email protected]>2019-09-04 17:19:56 +0800
committer陆秋文 <[email protected]>2019-09-04 17:20:25 +0800
commite40cd3ba7ffcb0fc776f97d8db66a5764327b784 (patch)
treed37638d3cda74ab0b09db40d0b74c648d6249b43 /plugin/protocol/http/src
parentcd67f0edb75d2c1aae027600ee9aed861ddfe20e (diff)
修正HTTP解析层在上层设置请求/应答后,需要等待源站消息完整后才将上层构建的请求/应答发出的问题。
* 原实现在HTTP解析过程中,只在HTTP消息的边界返回http_entry中的流程,故只能在站消息完整后才执行发出上层的请求/应答; * 现修正,在HTTP的解析过程中,发现上层设置了请求/应答,则在HTTP头部完整后执行PAUSE动作,触发上层请求/应答的发送流程。
Diffstat (limited to 'plugin/protocol/http/src')
-rw-r--r--plugin/protocol/http/src/http_half.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/plugin/protocol/http/src/http_half.cpp b/plugin/protocol/http/src/http_half.cpp
index d35f507..353ba2b 100644
--- a/plugin/protocol/http/src/http_half.cpp
+++ b/plugin/protocol/http/src/http_half.cpp
@@ -356,8 +356,8 @@ static int __parser_callback_on_headers_complete(http_parser * parser)
hf_private->stream_action = hf_private->user_stream_action;
}
- /* user's suspend tag is set, which indicate that the way to handle request/response
- * cannot be determinate at now, need to defer */
+ /* user's suspend tag is set, which indicate that the way to handle request/response
+ * cannot be determinate at now, need to defer */
else if (hs_private && hs_private->suspend_tag_signal)
{
/* Pause parser, prevent to parse request/response body,
@@ -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 */
assert(hf_private->stream_action == ACTION_DEFER_DATA);
}
-
- /* Otherwise, forward the request/response */
+ /* Otherwise, forward the request/response */
else
{
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;
}