New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assume ISO-8859-1 (instead of UTF-8) encoding for ASGI HTTP headers #1911
Comments
Hi 👋, Thanks for using Falcon. The large amount of time and effort needed to Please consider helping us secure the future of the Falcon framework with a Thank you for your support! |
Hi @n0w4k ! I'll schedule this for 3.1 to ensure we make a decision on this. I've tried digging into this quickly. It seems that, for instance, WSGI (PEP 3333) implies that headers should be treated as The popular Gunicorn server also opts to treat headers as In that light, I'm inclined to think that we probably don't want to support custom header encodings, but OTOH, it is a bug in Falcon's @kgriffs thoughts? |
@n0w4k Just to confirm, would defaulting to |
Thanks for the reply, @vytas7. I can confirm that all the bytes mentioned in the |
Right, thanks! It looks like almost all RFCs, WSGI servers and ASGI frameworks assume |
Currently, headers in Falcon's ASGI package will be decoded using the Python's default UTF-8 decoding.
For instance:
falcon/falcon/asgi/request.py
Line 847 in 9338511
and
falcon/falcon/asgi/request.py
Line 897 in 9338511
When headers have an encoding different from UTF-8, this leads to
UnicodeDecodeError
. An option to use different charsets here would be much appreciated.Even though headers are supposed to be plain ASCII where it doesn't matter, in reality, there are still headers sent which contain characters especially from the ISO-8859-1 charset. Compare also RFC 7230, section 3.2.4:
The text was updated successfully, but these errors were encountered: