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:
Flaper Fesp
2013-06-03 16:46:49 +02:00
parent 81e88344fb
commit 7daa976d14
2 changed files with 12 additions and 14 deletions
-11
View File
@@ -460,17 +460,6 @@ class ImageManagerTest(testtools.TestCase):
expect = [('PUT', '/v1/images/1', expect_headers, None)]
self.assertEqual(self.api.calls, expect)
def test_image_meta_to_headers_encoding(self):
# NOTE(flaper87): This doesn't make much sense
# _image_meta_to_headers decodes headers that will
# then be encoded before sending the request. If
# everything works as expected, there shouldn't be
# any need to enforce unicode in headers at this step.
# Will get rid of that in a separate patch.
fields = {"name": "ni\xc3\xb1o"}
headers = self.mgr._image_meta_to_headers(fields)
self.assertEqual(headers["x-image-meta-name"], u"ni\xf1o")
def test_image_meta_from_headers_encoding(self):
fields = {"x-image-meta-name": "ni\xc3\xb1o"}
headers = self.mgr._image_meta_from_headers(fields)