Suppress missing Content-Type headers when fetching content
Fixes #2572
This commit is contained in:
		| @@ -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: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user