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
1=== modified file 'swift/proxy/server.py'
2--- swift/proxy/server.py 2011-08-12 13:33:42 +0000
3+++ swift/proxy/server.py 2011-08-22 15:24:04 +0000
4@@ -819,13 +819,7 @@
5 yield obj
6 marker = sublisting[-1]['name']
7
8- headers = {
9- 'X-Object-Manifest': resp.headers['x-object-manifest'],
10- 'Content-Type': resp.content_type}
11- for key, value in resp.headers.iteritems():
12- if key.lower().startswith('x-object-meta-'):
13- headers[key] = value
14- resp = Response(headers=headers, request=req,
15+ resp = Response(headers=resp.headers, request=req,
16 conditional_response=True)
17 if req.method == 'HEAD':
18 # These shenanigans are because webob translates the HEAD
19@@ -859,20 +853,13 @@
20 content_length = 0
21 last_modified = resp.last_modified
22 etag = md5().hexdigest()
23- headers = {
24- 'X-Object-Manifest': resp.headers['x-object-manifest'],
25- 'Content-Type': resp.content_type,
26- 'Content-Length': content_length,
27- 'ETag': etag}
28- for key, value in resp.headers.iteritems():
29- if key.lower().startswith('x-object-meta-'):
30- headers[key] = value
31- resp = Response(headers=headers, request=req,
32+ resp = Response(headers=resp.headers, request=req,
33 conditional_response=True)
34 resp.app_iter = SegmentedIterable(self, lcontainer, listing,
35 resp)
36 resp.content_length = content_length
37 resp.last_modified = last_modified
38+ resp.etag = etag
39 resp.headers['accept-ranges'] = 'bytes'
40
41 return resp
42
43=== modified file 'test/unit/proxy/test_server.py'
44--- test/unit/proxy/test_server.py 2011-07-22 17:54:54 +0000
45+++ test/unit/proxy/test_server.py 2011-08-22 15:24:04 +0000
46@@ -71,7 +71,8 @@
47 mkdirs(os.path.join(_testdir, 'sdb1', 'tmp'))
48 _orig_container_listing_limit = proxy_server.CONTAINER_LISTING_LIMIT
49 conf = {'devices': _testdir, 'swift_dir': _testdir,
50- 'mount_check': 'false'}
51+ 'mount_check': 'false', 'allowed_headers':
52+ 'content-encoding, x-object-manifest, content-disposition, foo'}
53 prolis = listen(('localhost', 0))
54 acc1lis = listen(('localhost', 0))
55 acc2lis = listen(('localhost', 0))
56@@ -2437,7 +2438,8 @@
57 fd.write('PUT /v1/a/segmented/name HTTP/1.1\r\nHost: '
58 'localhost\r\nConnection: close\r\nX-Storage-Token: '
59 't\r\nContent-Length: 0\r\nX-Object-Manifest: '
60- 'segmented/name/\r\nContent-Type: text/jibberish\r\n\r\n')
61+ 'segmented/name/\r\nContent-Type: text/jibberish\r\n'
62+ 'Foo: barbaz\r\n\r\n')
63 fd.flush()
64 headers = readuntil2crlfs(fd)
65 exp = 'HTTP/1.1 201'
66@@ -2454,6 +2456,7 @@
67 self.assertEquals(headers[:len(exp)], exp)
68 self.assert_('X-Object-Manifest: segmented/name/' in headers)
69 self.assert_('Content-Type: text/jibberish' in headers)
70+ self.assert_('Foo: barbaz' in headers)
71 body = fd.read()
72 self.assertEquals(body, '1234 1234 1234 1234 1234 ')
73 # Do it again but exceeding the container listing limit