Using Tornado in Python 3.5, I have a problem setting Unicode character for HTTP Header. I need it to set the download file name in unicide (Content-Disposition header). But the following error would be occurred:
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 42-46: ordinal not in range(256)
According to Tornado documentation, in python 2, a decode to latin1 and re-encode to utf8 will perform if non-ascii characters are used. But in python 3 the following line cause the exception:
lines.extend(l.encode('latin1') for l in header_lines)