Merge "Use utils.convert_str to convert HTTP header values"

This commit is contained in:
Jenkins 2016-05-06 17:48:16 +00:00 committed by Gerrit Code Review
commit 1b13913525

View File

@ -21,7 +21,6 @@ import time
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import encodeutils
from oslo_utils import excutils
from oslo_utils import strutils
import six
@ -946,13 +945,7 @@ class Resource(wsgi.Application):
if hasattr(response, 'headers'):
for hdr, val in response.headers.items():
# Headers must be utf-8 strings
if six.PY2:
val = encodeutils.to_utf8(val)
else:
if isinstance(val, bytes):
val = val.decode('utf-8')
else:
val = str(val)
val = utils.convert_str(val)
response.headers[hdr] = val