I'm trying to set the Content-Disposition header in a Flask response object to a filenam which may contain Swedish characters (åäö). My test code looks like this:
response = flask.send_file(output_file_path)
response.headers[u"Content-Disposition"] = u'filename="åäö.pdf"'
This presents the following error:
File "C:\Python27\Lib\BaseHTTPServer.py", line 401, in send_header
self.wfile.write("%s: %s\r\n" % (keyword, value))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 10: ordinal
not in range(128)
I've tried encoding, decoding and just about anything I can think about, but I just cannot get Flask to accept that I want to use Unicode (utf-8) in my header!