From 00f65627285f4742752481948b5c685dbbfc8320 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 22 Feb 2020 19:07:17 -0500 Subject: [PATCH] Suppress missing Content-Type headers when fetching content Fixes #2572 --- discord/http.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/discord/http.py b/discord/http.py index 1eeff4d2a..4837bd2f0 100644 --- a/discord/http.py +++ b/discord/http.py @@ -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: