aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/http.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/discord/http.py b/discord/http.py
index 1eeff4d2..4837bd2f 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: