diff options
| author | Rapptz <[email protected]> | 2020-02-22 19:07:17 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2020-02-22 19:07:17 -0500 |
| commit | 00f65627285f4742752481948b5c685dbbfc8320 (patch) | |
| tree | 098fb7f5348342e35c2283c40da6e84315b4a3b2 | |
| parent | Fix invalid format specifier in PartialWebhookState.__getattr__ (diff) | |
| download | discord.py-00f65627285f4742752481948b5c685dbbfc8320.tar.xz discord.py-00f65627285f4742752481948b5c685dbbfc8320.zip | |
Suppress missing Content-Type headers when fetching content
Fixes #2572
| -rw-r--r-- | discord/http.py | 9 |
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: |