mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 09:22:03 +00:00
Check response content type.
This commit is contained in:
parent
a5766aad6f
commit
600148e6d2
1 changed files with 3 additions and 0 deletions
|
|
@ -50,6 +50,9 @@ async def _check_result(method_name, response):
|
|||
body = await response.text()
|
||||
log.debug(f"Response for {method_name}: [{response.status}] {body}")
|
||||
|
||||
if response.content_type != 'application/json':
|
||||
raise exceptions.NetworkError(f"Invalid response with content type {response.content_type}: \"{body}\"")
|
||||
|
||||
try:
|
||||
result_json = await response.json(loads=json.loads)
|
||||
except ValueError:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue