Skip to content

Commit

Permalink
Return 204 from DELETE /v2/images/<image_id>
Browse files Browse the repository at this point in the history
Fix bug 995224

The v2 API design and normal RESTful idiom would suggest that a
204 No Content status is more appropriate than 200 OK.

Change-Id: Ic5ae3ffa22eafdec0f780d16cceb8ce45c84c854
  • Loading branch information
Eoghan Glynn committed May 5, 2012
1 parent 6e65bf9 commit f184a38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion glance/api/v2/images.py
Expand Up @@ -60,7 +60,7 @@ def update(self, req, image_id, image):

def delete(self, req, image_id):
try:
return self.db_api.image_destroy(req.context, image_id)
self.db_api.image_destroy(req.context, image_id)
except exception.NotFound:
raise webob.exc.HTTPNotFound()

Expand Down Expand Up @@ -124,6 +124,9 @@ def index(self, response, images):
}
response.body = json.dumps(body)

def delete(self, response, result):
response.status_int = 204


def create_resource(conf):
"""Images resource factory method"""
Expand Down
2 changes: 1 addition & 1 deletion glance/tests/functional/v2/test_images.py
Expand Up @@ -99,7 +99,7 @@ def test_image_lifecycle(self):
# Deletion should work
path = self._url('/v2/images/%s' % image_id)
response = requests.delete(path, headers=self._headers())
self.assertEqual(200, response.status_code)
self.assertEqual(204, response.status_code)

# This image should be no longer be directly accessible
path = self._url('/v2/images/%s' % image_id)
Expand Down

0 comments on commit f184a38

Please sign in to comment.