Merge pull request #5131 from achillesrasquinha/py3

[FIX] gunicorn fails to read byte response headers, convert to strings
This commit is contained in:
Achilles Rasquinha 2018-03-08 01:21:25 +05:30 committed by GitHub
commit de88d2f568
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,12 +106,12 @@ def build_response(path, data, http_status_code, headers=None):
response = Response()
response.data = set_content_type(response, data, path)
response.status_code = http_status_code
response.headers[b"X-Page-Name"] = path.encode("utf-8")
response.headers[b"X-From-Cache"] = frappe.local.response.from_cache or False
response.headers["X-Page-Name"] = path.encode("utf-8")
response.headers["X-From-Cache"] = frappe.local.response.from_cache or False
if headers:
for key, val in iteritems(headers):
response.headers[bytes(key.encode("utf-8"))] = val.encode("utf-8")
response.headers[str(key.encode("utf-8"))] = val.encode("utf-8")
return response