From d63b40db172908f429adf36bacb600369ef8ef09 Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Thu, 3 Nov 2022 16:31:02 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20TSG-12514=20HTTP=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=B1=82=E6=9C=AA=E5=A4=84=E7=90=86chunk=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E7=9A=84POST=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/protocol/http/src/http_half.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin/protocol/http/src/http_half.cpp b/plugin/protocol/http/src/http_half.cpp index 658625b..8044812 100644 --- a/plugin/protocol/http/src/http_half.cpp +++ b/plugin/protocol/http/src/http_half.cpp @@ -308,8 +308,15 @@ static int __parser_callback_on_headers_complete(http_parser * parser) /* Does not contain a content-length, passthrough the whole TCP connection */ if (unlikely(__str_content_length == NULL)) { - hf_private->is_passthrough = true; - return -1; + const struct http_field_name __transfer_encoding_field_name = {TFE_HTTP_TRANSFER_ENCODING, NULL}; + char *__str_transfer_encoding = (char *)tfe_http_field_read(hf_public, &__transfer_encoding_field_name); + if (!(__str_transfer_encoding && strncasecmp(__str_transfer_encoding, "chunked", strlen("chunked")) == 0)) + { + const char * __str_stream = hf_private->session->hc_private->stream->str_stream_info; + TFE_LOG_ERROR(g_http_plugin->logger, "the content-length and transfer-encoding field not set, passthrough the whole tcp connection: %s. ", __str_stream); + hf_private->is_passthrough = true; + return -1; + } } }