mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Check for content-type after headers dict has been populated
This commit is contained in:
parent
773772c426
commit
7c61ac738e
1 changed files with 13 additions and 11 deletions
|
@ -247,17 +247,6 @@ def query(
|
|||
else:
|
||||
http_proxy_url = f"http://{proxy_host}:{proxy_port}"
|
||||
|
||||
if header_dict is None:
|
||||
header_dict = {}
|
||||
|
||||
if method == "POST" and "Content-Type" not in header_dict:
|
||||
log.debug(
|
||||
"Content-Type not provided for POST request, assuming application/x-www-form-urlencoded"
|
||||
)
|
||||
header_dict["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
if "Content-Length" not in header_dict:
|
||||
header_dict["Content-Length"] = f"{len(data)}"
|
||||
|
||||
match = re.match(
|
||||
r"https?://((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)($|/)",
|
||||
url,
|
||||
|
@ -364,6 +353,19 @@ def query(
|
|||
agent = f"{agent} http.query()"
|
||||
header_dict["User-agent"] = agent
|
||||
|
||||
if (
|
||||
proxy_host
|
||||
and proxy_port
|
||||
and method == "POST"
|
||||
and "Content-Type" not in header_dict
|
||||
):
|
||||
log.debug(
|
||||
"Content-Type not provided for POST request, assuming application/x-www-form-urlencoded"
|
||||
)
|
||||
header_dict["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
if "Content-Length" not in header_dict:
|
||||
header_dict["Content-Length"] = f"{len(data)}"
|
||||
|
||||
if backend == "requests":
|
||||
sess = requests.Session()
|
||||
sess.auth = auth
|
||||
|
|
Loading…
Add table
Reference in a new issue