Skip to content
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

Fix spanish character problem #46

Closed
wants to merge 1 commit into from
Closed

Conversation

pando85
Copy link

@pando85 pando85 commented Jan 6, 2016

This fix #45 in python 3.4 . I think it probably broke something in python2 but I don't know a best workaround for my problem right now.

@johnsensible
Copy link
Owner

I get this stack trace when I try to run the tests in Python 2.7 (Django 1.4):

======================================================================
ERROR: test_xaccelredirect_header_containing_unicode (sendfile.tests.TestNginxBackend)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/john/Development/ace/venv/local/lib/python2.7/site-packages/sendfile/tests.py", line 128, in test_xaccelredirect_header_containing_unicode
    response = real_sendfile(HttpRequest(), filepath)
  File "/home/john/Development/ace/venv/local/lib/python2.7/site-packages/sendfile/__init__.py", line 68, in sendfile
    response = _sendfile(request, filename, mimetype=mimetype)
  File "/home/john/Development/ace/venv/local/lib/python2.7/site-packages/sendfile/backends/nginx.py", line 11, in sendfile
    response['X-Accel-Redirect'] = url
  File "/home/john/Development/ace/venv/local/lib/python2.7/site-packages/django/http/__init__.py", line 610, in __setitem__
    header, value = self._convert_to_ascii(header, value)
  File "/home/john/Development/ace/venv/local/lib/python2.7/site-packages/django/http/__init__.py", line 599, in _convert_to_ascii
    value = value.encode('us-ascii')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 10: ordinal not in range(128), HTTP response headers must be in US-ASCII format

----------------------------------------------------------------------

Basically the trouble is that Django wants us-ascii data in the headers.

@pando85
Copy link
Author

pando85 commented Feb 12, 2016

Yep, this was a silly solution that works for my problem but I wasn't sure that it could work in python 2.

@pando85 pando85 closed this Feb 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with unicode characters
2 participants