Merge "Specified Content-Length in update request header"

This commit is contained in:
Jenkins
2012-09-10 23:38:06 +00:00
committed by Gerrit Code Review
2 changed files with 3 additions and 3 deletions

View File

@@ -218,16 +218,16 @@ class ImageManager(base.Manager):
TODO(bcwaldon): document accepted params TODO(bcwaldon): document accepted params
""" """
hdrs = {}
image_data = kwargs.pop('data', None) image_data = kwargs.pop('data', None)
if image_data is not None: if image_data is not None:
image_size = self._get_file_size(image_data) image_size = self._get_file_size(image_data)
if image_size != 0: if image_size != 0:
kwargs.setdefault('size', image_size) kwargs.setdefault('size', image_size)
hdrs['Content-Length'] = image_size
else: else:
image_data = None image_data = None
hdrs = {}
try: try:
purge_props = 'true' if kwargs.pop('purge_props') else 'false' purge_props = 'true' if kwargs.pop('purge_props') else 'false'
except KeyError: except KeyError:

View File

@@ -390,7 +390,7 @@ class ImageManagerTest(unittest.TestCase):
def test_update_with_data(self): def test_update_with_data(self):
image_data = StringIO.StringIO('XXX') image_data = StringIO.StringIO('XXX')
self.mgr.update('1', data=image_data) self.mgr.update('1', data=image_data)
expect_headers = {'x-image-meta-size': '3'} expect_headers = {'x-image-meta-size': '3', 'Content-Length': 3}
expect = [('PUT', '/v1/images/1', expect_headers, image_data)] expect = [('PUT', '/v1/images/1', expect_headers, image_data)]
self.assertEqual(self.api.calls, expect) self.assertEqual(self.api.calls, expect)