From dd223d547ddc9eb6b9912426cfb60864d85bc7de Mon Sep 17 00:00:00 2001 From: luqiuwen Date: Sat, 5 Jan 2019 18:18:39 +0600 Subject: [PATCH] =?UTF-8?q?Close=20#107=20=E4=B8=8D=E8=83=BD=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E5=A4=84=E7=90=86502=20Bad=20Gateway=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20*=20=E4=BF=AE=E6=AD=A3=E4=B8=BA=E5=BD=93HT?= =?UTF-8?q?TP=E8=AF=B7=E6=B1=82=E6=9C=AA=E5=AE=8C=E6=88=90=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=AE=A4=E4=B8=BA=E6=95=B4=E4=B8=AAHTTP=20Session?= =?UTF-8?q?=E9=9D=9E=E6=B3=95=EF=BC=8C=E4=B8=8D=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/protocol/http/src/http_entry.cpp | 18 ++++++++++++++---- 1 file 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; }