Skip to content

Commit

Permalink
Suppress missing Content-Type headers when fetching content
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Feb 23, 2020
1 parent 59ed908 commit 00f6562
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@

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:
Expand Down

0 comments on commit 00f6562

Please sign in to comment.