mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 16:00:29 +00:00
Suppress missing Content-Type headers when fetching content
Fixes #2572
This commit is contained in:
parent
59ed908ee2
commit
00f6562728
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user