Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: HTTP request header is overwritten when user set Content-Type (#5628)

非法操作92c56fdf2ba1
diff --git a/api/core/workflow/nodes/http_request/http_executor.py b/api/core/workflow/nodes/http_request/http_executor.py
index cafc432e33a..035a8604300 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']: