Do not decode headers in v1/images.py
v1.images._image_meta_to_headers currently encodes headers as a way to ensure they're an instance of basestring. This is not necessary since headers will be encoded later during the request. Also, all data within the client should be already decoded. Fixes bug: #1187013 Change-Id: I80525adbc6e9e576cfad5b576090ef9ee574c1cf
This commit is contained in:
@@ -77,11 +77,20 @@ class ImageManager(base.Manager):
|
||||
def _image_meta_to_headers(self, fields):
|
||||
headers = {}
|
||||
fields_copy = copy.deepcopy(fields)
|
||||
ensure_unicode = utils.ensure_unicode
|
||||
|
||||
# NOTE(flaper87): Convert to str, headers
|
||||
# that are not instance of basestring. All
|
||||
# headers will be encoded later, before the
|
||||
# request is sent.
|
||||
def to_str(value):
|
||||
if not isinstance(value, basestring):
|
||||
return str(value)
|
||||
return value
|
||||
|
||||
for key, value in fields_copy.pop('properties', {}).iteritems():
|
||||
headers['x-image-meta-property-%s' % key] = ensure_unicode(value)
|
||||
headers['x-image-meta-property-%s' % key] = to_str(value)
|
||||
for key, value in fields_copy.iteritems():
|
||||
headers['x-image-meta-%s' % key] = ensure_unicode(value)
|
||||
headers['x-image-meta-%s' % key] = to_str(value)
|
||||
return headers
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user