aiohttp is too strict when detecting charset in content_types #2197
Closed
Description
Long story short
The presence of a ; in a content type does not mean that it contains a charset.
Expected behaviour
Only complain about charsets if there's a charset in content_type.
Actual behaviour
text/plain; version=0.0.4 will raise an ValueError: charset must not be in content_type argument.
The problem are these lines:
aiohttp/aiohttp/web_response.py
Lines 456 to 458 in 4b498d1
aiohttp just checks for a semicolon instead for the actual word charset.
Steps to reproduce
>>> from aiohttp.web import Response
>>> Response(text="hello", content_type="text/plain; version=0.0.4", charset="utf-8")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hynek/.virtualenvs/prometheus_async/lib/python3.6/site-packages/aiohttp/web_response.py", line 451, in __init__
raise ValueError("charset must not be in content_type "
ValueError: charset must not be in content_type argument
charset must not be in content_type argument