Quellcode durchsuchen

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

非法操作 vor 10 Monaten
Ursprung
Commit
92c56fdf2b
1 geänderte Dateien mit 3 neuen und 2 gelöschten Zeilen
  1. 3 2
      api/core/workflow/nodes/http_request/http_executor.py

+ 3 - 2
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']: