summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluqiuwen <[email protected]>2019-01-05 18:18:39 +0600
committerluqiuwen <[email protected]>2019-01-05 18:18:39 +0600
commitdd223d547ddc9eb6b9912426cfb60864d85bc7de (patch)
tree635599eb95eb2a6e4e93688b4067b97904e65148
parenta91feaf7edd616a8fa0ca02c7c906cf74652619a (diff)
Close #107 不能正确处理502 Bad Gateway的问题
* 修正为当HTTP请求未完成时,认为整个HTTP Session非法,不处理。
-rw-r--r--plugin/protocol/http/src/http_entry.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/plugin/protocol/http/src/http_entry.cpp b/plugin/protocol/http/src/http_entry.cpp
index 9d2f245..141d3ff 100644
--- a/plugin/protocol/http/src/http_entry.cpp
+++ b/plugin/protocol/http/src/http_entry.cpp
@@ -223,7 +223,7 @@ static int __on_request_handle_user_req_or_resp(const tfe_stream * stream, struc
ret = __write_http_half_to_line(stream, CONN_DIR_UPSTREAM, hf_private_req_user);
if (unlikely(ret < 0))
{
- TFE_STREAM_LOG_ERROR(stream, "Failed to write HTTP request setup by user. ");
+ TFE_LOG_ERROR(g_http_plugin->logger, "Failed to write HTTP request setup by user. ");
return ret;
}
@@ -246,7 +246,7 @@ static int __on_request_handle_user_req_or_resp(const tfe_stream * stream, struc
if (unlikely(ret < 0))
{
- TFE_STREAM_LOG_ERROR(stream, "Failed to write HTTP request setup by user.");
+ TFE_LOG_ERROR(g_http_plugin->logger, "Failed to write HTTP request setup by user.");
goto __errout;
}
@@ -271,7 +271,7 @@ static int __on_response_handle_user_req_or_resp(const tfe_stream * stream, stru
int ret = __write_http_half_to_line(stream, CONN_DIR_DOWNSTREAM, hf_private_resp_user);
if (unlikely(ret < 0))
{
- TFE_STREAM_LOG_ERROR(stream, "Failed to write HTTP response setup by user.");
+ TFE_LOG_ERROR(g_http_plugin->logger, "Failed to write HTTP response setup by user.");
return -1;
}
@@ -328,7 +328,17 @@ static int __on_response_prepare_context(const struct tfe_stream * stream, unsig
/* Standalone response, it means missing something or malformed http protocol */
if (hs_private == NULL)
{
- TFE_STREAM_LOG_ERROR(stream, "Standlone HTTP response emerged. Malformed HTTP Protocol, detached. ");
+ TFE_LOG_ERROR(g_http_plugin->logger, "Standlone HTTP response emerged. Malformed HTTP Protocol, detached. ");
+ return -1;
+ }
+
+ struct http_half_private * hf_private_req_in = to_hf_request_private(hs_private);
+
+ /* The request is not completed, but response arrival.
+ * Something wrong happends to server, like 502 bad gateway */
+ if(hf_private_req_in->message_status != STATUS_COMPLETE)
+ {
+ TFE_LOG_ERROR(g_http_plugin->logger, "Response arrival when request is not completed, detached. ");
return -1;
}