Merge lp:~jaypipes/glance/bug719825 into lp:~glance-coresec/glance/cactus-trunk

Proposed by Jay Pipes
Status: Merged
Approved by: Devin Carlen
Approved revision: 72
Merged at revision: 72
Proposed branch: lp:~jaypipes/glance/bug719825
Merge into: lp:~glance-coresec/glance/cactus-trunk
Prerequisite: lp:~jaypipes/glance/bug719834
Diff against target: 37 lines (+15/-1)
2 files modified
glance/server.py (+7/-1)
tests/unit/test_api.py (+8/-0)
To merge this branch: bzr merge lp:~jaypipes/glance/bug719825
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Soren Hansen (community) Approve
Rick Harris Pending
Review via email: mp+49941@code.launchpad.net

Commit message

Adds Location: header to return from API server for POST /images, per APP spec

Description of the change

Adds Location: header to return from API server for POST /images, per APP spec

To post a comment you must log in.
Revision history for this message
Soren Hansen (soren) wrote :

lgtm

review: Approve
Revision history for this message
Devin Carlen (devcamcar) 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/server.py'
2--- glance/server.py 2011-02-06 14:08:14 +0000
3+++ glance/server.py 2011-02-16 10:04:59 +0000
4@@ -341,7 +341,13 @@
5 location = req.headers['x-image-meta-location']
6 self._activate(req, image_meta, location)
7
8- return dict(image=image_meta)
9+ # APP states we should return a Location: header with the edit
10+ # URI of the resource newly-created.
11+ res = Response(request=req, body=json.dumps(dict(image=image_meta)),
12+ content_type="text/plain")
13+ res.headers.add('Location', "/images/%s" % image_meta['id'])
14+
15+ return req.get_response(res)
16
17 def update(self, req, id):
18 """
19
20=== modified file 'tests/unit/test_api.py'
21--- tests/unit/test_api.py 2011-02-05 07:40:39 +0000
22+++ tests/unit/test_api.py 2011-02-16 10:04:59 +0000
23@@ -288,6 +288,14 @@
24 self.assertEquals(res_body['location'],
25 'file:///tmp/glance-tests/3')
26
27+ # Test that the Location: header is set to the URI to
28+ # edit the newly-created image, as required by APP.
29+ # See LP Bug #719825
30+ self.assertTrue('location' in res.headers,
31+ "'location' not in response headers.\n"
32+ "res.headerlist = %r" % res.headerlist)
33+ self.assertTrue('/images/3' in res.headers['location'])
34+
35 def test_image_meta(self):
36 """Test for HEAD /images/<ID>"""
37 expected_headers = {'x-image-meta-id': 2,

Subscribers

People subscribed via source and target branches