Use utils.convert_str to convert HTTP header values
This patch removes duplicate code between wsgi.py and utils.py modules. Change-Id: Ic3eefc2bc28ff202324e7859102b289aac7974d4
This commit is contained in:
parent
3c04ab1e2a
commit
74c8f65342
@ -25,7 +25,6 @@ from lxml import etree
|
||||
from oslo_log import log as logging
|
||||
from oslo_log import versionutils
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
@ -1166,13 +1165,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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user