Encode header values using latin-1, not ascii
twoyang0917 opened this issue · comments
.venv/lib/python3.10/site-packages/hypercorn/app_wrappers.py", line 102, in <listcomp>
(name.lower().encode("ascii"), value.encode("ascii"))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 21-32: ordinal not in range(128)
I ran an wsgi app via AsyncioWSGIMiddleware. I meet this error when I download a file with filename contains special characters.
I did some investgation, it should be a bug. PEP3333 said that even if Python’s str type is actually Unicode “under the hood”, the content of native strings must still be translatable to bytes via the Latin-1 encoding!
and the same issue has been fixed by gunicorn
benoitc/gunicorn#1914