Skip to content

Commit

Permalink
Prepend '/' to the delete url for the v2 client
Browse files Browse the repository at this point in the history
... and update tests to match.

The missing slash results in a non-absolute DELETE request
being sent to the API.
E.g.
DELETE v2/images/62fac489-23b4-4929-87af-2e7236e8542b HTTP/1.1

This is not strictly valid http/1.1 - rfc2616 specifies that the path must
be absolute.
This doesn't cause a problem for the API server, but this can cause
problems if the API server is fronted by something else (see #133161).

It also means that the curl command logged in debug mode has a
bad url.
E.g.
curl -i -X DELETE ... http://10.0.0.13:9292v2/images/...

Change-Id: Ib0c749dedbfcf07303fcddae4512db61b0f3fd78
Closes-bug: #1327101
  • Loading branch information
Manuel Desbonnet committed Jun 23, 2014
1 parent 938031a commit a945b3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion glanceclient/v2/images.py
Expand Up @@ -117,7 +117,7 @@ def upload(self, image_id, image_data, image_size=None):

def delete(self, image_id):
"""Delete an image."""
self.http_client.json_request('DELETE', 'v2/images/%s' % image_id)
self.http_client.json_request('DELETE', '/v2/images/%s' % image_id)

def create(self, **kwargs):
"""Create an image."""
Expand Down
4 changes: 2 additions & 2 deletions tests/v2/test_images.py
Expand Up @@ -118,7 +118,7 @@
},
),
},
'v2/images/87b634c1-f893-33c9-28a9-e5673c99239a': {
'/v2/images/87b634c1-f893-33c9-28a9-e5673c99239a': {
'DELETE': (
{},
{
Expand Down Expand Up @@ -496,7 +496,7 @@ def test_delete_image(self):
self.controller.delete('87b634c1-f893-33c9-28a9-e5673c99239a')
expect = [
('DELETE',
'v2/images/87b634c1-f893-33c9-28a9-e5673c99239a',
'/v2/images/87b634c1-f893-33c9-28a9-e5673c99239a',
{},
None)]
self.assertEqual(expect, self.api.calls)
Expand Down

0 comments on commit a945b3d

Please sign in to comment.