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):
|
async def json_or_text(response):
|
||||||
text = await response.text(encoding='utf-8')
|
text = await response.text(encoding='utf-8')
|
||||||
|
try:
|
||||||
if response.headers['content-type'] == 'application/json':
|
if response.headers['content-type'] == 'application/json':
|
||||||
return json.loads(text)
|
return json.loads(text)
|
||||||
|
except KeyError:
|
||||||
|
# Thanks Cloudflare
|
||||||
|
pass
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
class Route:
|
class Route:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user