Merge lp:~notmyname/swift/manifest_headers into lp:~hudson-openstack/swift/trunk

Proposed by John Dickinson
Status: Merged
Approved by: gholt
Approved revision: 347
Merged at revision: 347
Proposed branch: lp:~notmyname/swift/manifest_headers
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 73 lines (+8/-18)
2 files modified
swift/proxy/server.py (+3/-16)
test/unit/proxy/test_server.py (+5/-2)
To merge this branch: bzr merge lp:~notmyname/swift/manifest_headers
Reviewer Review Type Date Requested Status
Greg Lange (community) Approve
gholt (community) Approve
Review via email: mp+72443@code.launchpad.net

Description of the change

updated the proxy to return all headers stored for manifest objects

To post a comment you must log in.
Revision history for this message
gholt (gholt) :
review: Approve
Revision history for this message
Greg Lange (greglange) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'swift/proxy/server.py'
--- swift/proxy/server.py 2011-08-12 13:33:42 +0000
+++ swift/proxy/server.py 2011-08-22 15:24:04 +0000
@@ -819,13 +819,7 @@
819 yield obj819 yield obj
820 marker = sublisting[-1]['name']820 marker = sublisting[-1]['name']
821821
822 headers = {822 resp = Response(headers=resp.headers, request=req,
823 'X-Object-Manifest': resp.headers['x-object-manifest'],
824 'Content-Type': resp.content_type}
825 for key, value in resp.headers.iteritems():
826 if key.lower().startswith('x-object-meta-'):
827 headers[key] = value
828 resp = Response(headers=headers, request=req,
829 conditional_response=True)823 conditional_response=True)
830 if req.method == 'HEAD':824 if req.method == 'HEAD':
831 # These shenanigans are because webob translates the HEAD825 # These shenanigans are because webob translates the HEAD
@@ -859,20 +853,13 @@
859 content_length = 0853 content_length = 0
860 last_modified = resp.last_modified854 last_modified = resp.last_modified
861 etag = md5().hexdigest()855 etag = md5().hexdigest()
862 headers = {856 resp = Response(headers=resp.headers, request=req,
863 'X-Object-Manifest': resp.headers['x-object-manifest'],
864 'Content-Type': resp.content_type,
865 'Content-Length': content_length,
866 'ETag': etag}
867 for key, value in resp.headers.iteritems():
868 if key.lower().startswith('x-object-meta-'):
869 headers[key] = value
870 resp = Response(headers=headers, request=req,
871 conditional_response=True)857 conditional_response=True)
872 resp.app_iter = SegmentedIterable(self, lcontainer, listing,858 resp.app_iter = SegmentedIterable(self, lcontainer, listing,
873 resp)859 resp)
874 resp.content_length = content_length860 resp.content_length = content_length
875 resp.last_modified = last_modified861 resp.last_modified = last_modified
862 resp.etag = etag
876 resp.headers['accept-ranges'] = 'bytes'863 resp.headers['accept-ranges'] = 'bytes'
877864
878 return resp865 return resp
879866
=== modified file 'test/unit/proxy/test_server.py'
--- test/unit/proxy/test_server.py 2011-07-22 17:54:54 +0000
+++ test/unit/proxy/test_server.py 2011-08-22 15:24:04 +0000
@@ -71,7 +71,8 @@
71 mkdirs(os.path.join(_testdir, 'sdb1', 'tmp'))71 mkdirs(os.path.join(_testdir, 'sdb1', 'tmp'))
72 _orig_container_listing_limit = proxy_server.CONTAINER_LISTING_LIMIT72 _orig_container_listing_limit = proxy_server.CONTAINER_LISTING_LIMIT
73 conf = {'devices': _testdir, 'swift_dir': _testdir,73 conf = {'devices': _testdir, 'swift_dir': _testdir,
74 'mount_check': 'false'}74 'mount_check': 'false', 'allowed_headers':
75 'content-encoding, x-object-manifest, content-disposition, foo'}
75 prolis = listen(('localhost', 0))76 prolis = listen(('localhost', 0))
76 acc1lis = listen(('localhost', 0))77 acc1lis = listen(('localhost', 0))
77 acc2lis = listen(('localhost', 0))78 acc2lis = listen(('localhost', 0))
@@ -2437,7 +2438,8 @@
2437 fd.write('PUT /v1/a/segmented/name HTTP/1.1\r\nHost: '2438 fd.write('PUT /v1/a/segmented/name HTTP/1.1\r\nHost: '
2438 'localhost\r\nConnection: close\r\nX-Storage-Token: '2439 'localhost\r\nConnection: close\r\nX-Storage-Token: '
2439 't\r\nContent-Length: 0\r\nX-Object-Manifest: '2440 't\r\nContent-Length: 0\r\nX-Object-Manifest: '
2440 'segmented/name/\r\nContent-Type: text/jibberish\r\n\r\n')2441 'segmented/name/\r\nContent-Type: text/jibberish\r\n'
2442 'Foo: barbaz\r\n\r\n')
2441 fd.flush()2443 fd.flush()
2442 headers = readuntil2crlfs(fd)2444 headers = readuntil2crlfs(fd)
2443 exp = 'HTTP/1.1 201'2445 exp = 'HTTP/1.1 201'
@@ -2454,6 +2456,7 @@
2454 self.assertEquals(headers[:len(exp)], exp)2456 self.assertEquals(headers[:len(exp)], exp)
2455 self.assert_('X-Object-Manifest: segmented/name/' in headers)2457 self.assert_('X-Object-Manifest: segmented/name/' in headers)
2456 self.assert_('Content-Type: text/jibberish' in headers)2458 self.assert_('Content-Type: text/jibberish' in headers)
2459 self.assert_('Foo: barbaz' in headers)
2457 body = fd.read()2460 body = fd.read()
2458 self.assertEquals(body, '1234 1234 1234 1234 1234 ')2461 self.assertEquals(body, '1234 1234 1234 1234 1234 ')
2459 # Do it again but exceeding the container listing limit2462 # Do it again but exceeding the container listing limit