Suppress missing Content-Type headers when fetching content

Fixes #2572
This commit is contained in:
Rapptz 2020-02-22 19:07:17 -05:00
parent 59ed908ee2
commit 00f6562728

View File

@ -40,8 +40,13 @@ log = logging.getLogger(__name__)
async def json_or_text(response):
text = await response.text(encoding='utf-8')
if response.headers['content-type'] == 'application/json':
return json.loads(text)
try:
if response.headers['content-type'] == 'application/json':
return json.loads(text)
except KeyError:
# Thanks Cloudflare
pass
return text
class Route: