A recent change to the wsgi code broke deployments running over
httpd/mod_wsgi. This is because for py2.X mod_wsgi accepts byte
strings and breaks with utf8. However, for py3.X, utf8 is
accepted. So this acts accordingly.
Change-Id: I81739bc3de9d623b718987b5fc18eaf851533902
Closes-Bug: #
1643511
if hasattr(response, 'headers'):
for hdr, val in list(response.headers.items()):
- # Headers must be utf-8 strings
- response.headers[hdr] = encodeutils.safe_decode(
- utils.utf8(val))
+ if six.PY2:
+ # In Py2.X Headers must be byte strings
+ response.headers[hdr] = utils.utf8(val)
+ else:
+ # In Py3.X Headers must be utf-8 strings
+ response.headers[hdr] = encodeutils.safe_decode(
+ utils.utf8(val))
if not request.api_version_request.is_null():
response.headers[API_VERSION_REQUEST_HEADER] = \