Merge lp:~rackspace-titan/glance/multiple-content-types-lp800947 into lp:~hudson-openstack/glance/trunk

Proposed by Brian Waldon
Status: Merged
Approved by: Jay Pipes
Approved revision: 146
Merged at revision: 144
Proposed branch: lp:~rackspace-titan/glance/multiple-content-types-lp800947
Merge into: lp:~hudson-openstack/glance/trunk
Diff against target: 81 lines (+10/-9)
3 files modified
glance/api/v1/images.py (+7/-7)
tests/functional/test_httplib2_api.py (+1/-2)
tests/unit/test_api.py (+2/-0)
To merge this branch: bzr merge lp:~rackspace-titan/glance/multiple-content-types-lp800947
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Mark Washenberger (community) Approve
Review via email: mp+65831@code.launchpad.net

Description of the change

Explicitly set headers rather than add them

To post a comment you must log in.
Revision history for this message
Mark Washenberger (markwash) wrote :

This looks good to me, and I believe it will fix the one failing test in the functional test merge prop. However, I would like to see that same failure (or rather the fact that it should succeed in this branch!) documented in some unit tests as well. :-)

144. By Brian Waldon

adding assert to check content_type in GET /images/<id> test

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Check it now. I added an assert, merged in trunk (the httplib2 branch), and updated the problem test.

145. By Brian Waldon

merging trunk

146. By Brian Waldon

fixing httplib2 functional test that was expecting wrong content-type value

Revision history for this message
Mark Washenberger (markwash) wrote :

Cool.

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'glance/api/v1/images.py'
2--- glance/api/v1/images.py 2011-06-17 20:45:45 +0000
3+++ glance/api/v1/images.py 2011-06-24 21:18:33 +0000
4@@ -525,10 +525,10 @@
5
6 def _inject_location_header(self, response, image_meta):
7 location = self._get_image_location(image_meta)
8- response.headers.add('Location', location)
9+ response.headers['Location'] = location
10
11 def _inject_checksum_header(self, response, image_meta):
12- response.headers.add('ETag', image_meta['checksum'])
13+ response.headers['ETag'] = image_meta['checksum']
14
15 def _inject_image_meta_headers(self, response, image_meta):
16 """
17@@ -545,7 +545,7 @@
18 headers = utils.image_meta_to_http_headers(image_meta)
19
20 for k, v in headers.items():
21- response.headers.add(k, v)
22+ response.headers[k] = v
23
24 def _get_image_location(self, image_meta):
25 """Build a relative url to reach the image defined by image_meta."""
26@@ -563,8 +563,8 @@
27
28 response.app_iter = result['image_iterator']
29 # Using app_iter blanks content-length, so we set it here...
30- response.headers.add('Content-Length', image_meta['size'])
31- response.headers.add('Content-Type', 'application/octet-stream')
32+ response.headers['Content-Length'] = image_meta['size']
33+ response.headers['Content-Type'] = 'application/octet-stream'
34
35 self._inject_image_meta_headers(response, image_meta)
36 self._inject_location_header(response, image_meta)
37@@ -575,7 +575,7 @@
38 def update(self, response, result):
39 image_meta = result['image_meta']
40 response.body = self.to_json(dict(image=image_meta))
41- response.headers.add('Content-Type', 'application/json')
42+ response.headers['Content-Type'] = 'application/json'
43 self._inject_location_header(response, image_meta)
44 self._inject_checksum_header(response, image_meta)
45 return response
46@@ -583,7 +583,7 @@
47 def create(self, response, result):
48 image_meta = result['image_meta']
49 response.status = httplib.CREATED
50- response.headers.add('Content-Type', 'application/json')
51+ response.headers['Content-Type'] = 'application/json'
52 response.body = self.to_json(dict(image=image_meta))
53 self._inject_location_header(response, image_meta)
54 self._inject_checksum_header(response, image_meta)
55
56=== modified file 'tests/functional/test_httplib2_api.py'
57--- tests/functional/test_httplib2_api.py 2011-06-22 18:04:19 +0000
58+++ tests/functional/test_httplib2_api.py 2011-06-24 21:18:33 +0000
59@@ -135,8 +135,7 @@
60
61 expected_std_headers = {
62 'content-length': str(FIVE_KB),
63- 'content-type':
64- 'text/html; charset=UTF-8, application/octet-stream'}
65+ 'content-type': 'application/octet-stream'}
66
67 for expected_key, expected_value in expected_image_headers.items():
68 self.assertEqual(response[expected_key], expected_value,
69
70=== modified file 'tests/unit/test_api.py'
71--- tests/unit/test_api.py 2011-06-21 16:31:54 +0000
72+++ tests/unit/test_api.py 2011-06-24 21:18:33 +0000
73@@ -1148,6 +1148,8 @@
74 def test_show_image_basic(self):
75 req = webob.Request.blank("/images/2")
76 res = req.get_response(self.api)
77+ self.assertEqual(res.status_int, 200)
78+ self.assertEqual(res.content_type, 'application/octet-stream')
79 self.assertEqual('chunk00000remainder', res.body)
80
81 def test_show_non_exists_image(self):

Subscribers

People subscribed via source and target branches