Check response content type.

This commit is contained in:
Alex Root Junior 2017-11-16 17:56:27 +02:00
parent a5766aad6f
commit 600148e6d2

View file

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