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

This commit is contained in:
非法操作 2024-06-27 12:31:37 +08:00 committed by GitHub
parent dcb72e0067
commit 92c56fdf2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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']: