From 92c56fdf2ba1b1fc4b117f1d9b97c2d08868b0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Thu, 27 Jun 2024 12:31:37 +0800 Subject: [PATCH] fix: HTTP request header is overwritten when user set Content-Type (#5628) --- api/core/workflow/nodes/http_request/http_executor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/core/workflow/nodes/http_request/http_executor.py b/api/core/workflow/nodes/http_request/http_executor.py index cafc432e33..035a860430 100644 --- a/api/core/workflow/nodes/http_request/http_executor.py +++ b/api/core/workflow/nodes/http_request/http_executor.py @@ -168,9 +168,10 @@ class HttpExecutor: if body_data: body_data, body_data_variable_selectors = self._format_template(body_data, variable_pool, is_valid_json) - if node_data.body.type == 'json': + content_type_is_set = any(key.lower() == 'content-type' for key in self.headers) + if node_data.body.type == 'json' and not content_type_is_set: self.headers['Content-Type'] = 'application/json' - elif node_data.body.type == 'x-www-form-urlencoded': + elif node_data.body.type == 'x-www-form-urlencoded' and not content_type_is_set: self.headers['Content-Type'] = 'application/x-www-form-urlencoded' if node_data.body.type in ['form-data', 'x-www-form-urlencoded']: