diff --git a/swift/common/middleware/account_quotas.py b/swift/common/middleware/account_quotas.py index ec4a3fda2e..a3c7dc96cd 100644 --- a/swift/common/middleware/account_quotas.py +++ b/swift/common/middleware/account_quotas.py @@ -53,8 +53,7 @@ account size has been updated. """ from swift.common.constraints import check_copy_from_header -from swift.common.swob import HTTPForbidden, HTTPRequestEntityTooLarge, \ - HTTPBadRequest, wsgify +from swift.common.swob import HTTPForbidden, Response, HTTPBadRequest, wsgify from swift.common.utils import register_swift_info from swift.proxy.controllers.base import get_account_info, get_object_info @@ -137,7 +136,7 @@ class AccountQuotaMiddleware(object): new_size = int(account_info['bytes']) + content_length if quota < new_size: - return HTTPRequestEntityTooLarge() + return Response(status=413, body='Upload exceeds quota.') return self.app diff --git a/test/unit/common/middleware/test_account_quotas.py b/test/unit/common/middleware/test_account_quotas.py index 8660cf5e48..75bd1d70eb 100644 --- a/test/unit/common/middleware/test_account_quotas.py +++ b/test/unit/common/middleware/test_account_quotas.py @@ -140,6 +140,7 @@ class TestAccountQuota(unittest.TestCase): 'swift.cache': cache}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_over_quota_container_create_still_works(self): headers = [('x-account-bytes-used', '1001'), @@ -189,6 +190,7 @@ class TestAccountQuota(unittest.TestCase): headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_exceed_bytes_quota_copy_verb(self): headers = [('x-account-bytes-used', '500'), @@ -202,6 +204,7 @@ class TestAccountQuota(unittest.TestCase): headers={'Destination': '/c/o'}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_not_exceed_bytes_quota_copy_from(self): headers = [('x-account-bytes-used', '0'), diff --git a/test/unit/common/middleware/test_quotas.py b/test/unit/common/middleware/test_quotas.py index da060e1229..b0548cc56c 100644 --- a/test/unit/common/middleware/test_quotas.py +++ b/test/unit/common/middleware/test_quotas.py @@ -93,6 +93,7 @@ class TestContainerQuotas(unittest.TestCase): 'CONTENT_LENGTH': '100'}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_exceed_bytes_quota_copy_from(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -105,6 +106,7 @@ class TestContainerQuotas(unittest.TestCase): headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_exceed_bytes_quota_copy_verb(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -117,6 +119,7 @@ class TestContainerQuotas(unittest.TestCase): headers={'Destination': '/c/o'}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_not_exceed_bytes_quota(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -191,6 +194,7 @@ class TestContainerQuotas(unittest.TestCase): 'CONTENT_LENGTH': '100'}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_exceed_counts_quota_copy_from(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -202,6 +206,7 @@ class TestContainerQuotas(unittest.TestCase): headers={'x-copy-from': '/c2/o2'}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_exceed_counts_quota_copy_verb(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {}) @@ -212,6 +217,7 @@ class TestContainerQuotas(unittest.TestCase): headers={'Destination': '/c/o'}) res = req.get_response(app) self.assertEquals(res.status_int, 413) + self.assertEquals(res.body, 'Upload exceeds quota.') def test_not_exceed_counts_quota(self): app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})