-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
wsgi.py > send_headers: encoding problem. #1353
Comments
This is a bit of a grey area, but one thing is clear: Now, 5f4ebd2 changed latin-1 to ascii. The referenced standards do suggest that headers should be in ASCII. gunicorn is being particularly strict here, and it could be argued that it should go back to latin-1 encoding, but that raises other potential interoperability concerns. (Do your applications and clients work successfully with latin-1?) This could be a Python 2/Python 3 thing, since the version isn't specified. If this code is running on Python 2, the bug is in the user code that sets the header, because the header should already be a bytes/str object, not unicode. |
I'm using python 3. All this seems kinda problematic and I guess that the proper solution would be then that I use only I'll keep using
For the moment everything seems to work good and it fixes a critical bug since most of the filenames have special characters! (I'll maybe switch to |
I'm going to close this as it's well documented around the web that HTTP headers should be ASCII, unfortunately. @rsm-gh you may wish to change your application to add the information you need to the response body, rather than the headers, if possible. |
Because this is |
if your problem is downloading file with filename in unicode like me, you can try this:
|
Seems the proper way to do this would be using |
While serving a file with
django
andnginx
I got an encoding error coming fromgunicorn
. The problem is that thesend_headers
method tries to convert theheader_str
in toascii
while sometimes it is necessary to useutf-8
for serving paths with special characters.I just changed
ascii
in toutf-8
to fix my problem, but maybe there should be some setting to change this.And in case that you be curious of how I was using the
Response
object, I got it from anHTTPResponse
fromdjango
:The text was updated successfully, but these errors were encountered: