Skip to content

Commit

Permalink
Return 413 when image_size_cap exceeded
Browse files Browse the repository at this point in the history
HTTP Error 413 (Request entity too large) may be the most appropriate
response when a request to upload an image whose size exceeds
image_size_cap is made.

Addresses bug 1158711.

Change-Id: I4abcb3a8b57c080b5a1b512f9694b2d75a4e5e9d
  • Loading branch information
Stuart McLaren committed Mar 22, 2013
1 parent a3c0a5f commit 91f538f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions glance/api/v1/images.py
Expand Up @@ -511,8 +511,8 @@ def _kill_mismatched(image_meta, attr, actual):
% CONF.image_size_cap)
LOG.info(msg)
self._safe_kill(req, image_id)
raise HTTPBadRequest(explanation=msg, request=req,
content_type='text/plain')
raise HTTPRequestEntityTooLarge(explanation=msg, request=req,
content_type='text/plain')

except HTTPError, e:
self._safe_kill(req, image_id)
Expand Down
4 changes: 2 additions & 2 deletions glance/tests/unit/v1/test_api.py
Expand Up @@ -2172,7 +2172,7 @@ def test_add_image_size_chunked_data_too_big(self):
req.headers[k] = v

res = req.get_response(self.api)
self.assertEquals(res.status_int, 400)
self.assertEquals(res.status_int, 413)

def test_add_image_size_data_too_big(self):
self.config(image_size_cap=512)
Expand Down Expand Up @@ -2677,7 +2677,7 @@ def test_update_image_size_chunked_data_too_big(self):
req.headers[k] = v

res = req.get_response(self.api)
self.assertEquals(res.status_int, 400)
self.assertEquals(res.status_int, 413)

def test_get_index_sort_name_asc(self):
"""
Expand Down

0 comments on commit 91f538f

Please sign in to comment.