Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions api/core/workflow/nodes/http_request/http_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ def _init_template(self, node_data: HttpRequestNodeData, variable_pool: Optional
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']:
Expand Down