Merge pull request #26656 from akhilnarang/request-check-content-type
fix(make_request): don't blindly try to check the content-type
This commit is contained in:
commit
fb2df4ab5e
1 changed files with 9 additions and 9 deletions
|
|
@ -21,15 +21,15 @@ def make_request(method: str, url: str, auth=None, headers=None, data=None, json
|
|||
)
|
||||
response.raise_for_status()
|
||||
|
||||
content_type = response.headers.get("content-type")
|
||||
if content_type == "text/plain; charset=utf-8":
|
||||
return parse_qs(response.text)
|
||||
elif content_type.startswith("application/") and content_type.split(";")[0].endswith("json"):
|
||||
return response.json()
|
||||
elif response.text:
|
||||
return response.text
|
||||
else:
|
||||
return
|
||||
# Check whether the response has a content-type, before trying to check what it is
|
||||
if content_type := response.headers.get("content-type"):
|
||||
if content_type == "text/plain; charset=utf-8":
|
||||
return parse_qs(response.text)
|
||||
elif content_type.startswith("application/") and content_type.split(";")[0].endswith("json"):
|
||||
return response.json()
|
||||
elif response.text:
|
||||
return response.text
|
||||
return
|
||||
except Exception as exc:
|
||||
if frappe.flags.integration_request_doc:
|
||||
frappe.flags.integration_request_doc.log_error()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue