diff --git a/swift3/middleware.py b/swift3/middleware.py index 14623863..79df9cfb 100644 --- a/swift3/middleware.py +++ b/swift3/middleware.py @@ -71,7 +71,7 @@ from swift.common.http import HTTP_OK, HTTP_CREATED, HTTP_ACCEPTED, \ HTTP_NO_CONTENT, HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED, HTTP_FORBIDDEN, \ HTTP_NOT_FOUND, HTTP_CONFLICT, HTTP_UNPROCESSABLE_ENTITY, is_success, \ HTTP_NOT_IMPLEMENTED, HTTP_LENGTH_REQUIRED, HTTP_SERVICE_UNAVAILABLE, \ - HTTP_REQUEST_ENTITY_TOO_LARGE + HTTP_REQUEST_ENTITY_TOO_LARGE, HTTP_METHOD_NOT_ALLOWED MAX_BUCKET_LISTING = 1000 @@ -112,6 +112,9 @@ def get_err_response(code): 'EntityTooLarge': (HTTP_BAD_REQUEST, 'Your proposed upload exceeds the maximum ' 'allowed object size.'), + 'MethodNotAllowed': + (HTTP_METHOD_NOT_ALLOWED, 'The specified method is not allowed ' + 'against this resource.'), 'NoSuchBucket': (HTTP_NOT_FOUND, 'The specified bucket does not exist'), 'SignatureDoesNotMatch': @@ -950,7 +953,7 @@ class Swift3Middleware(object): if hasattr(controller, req.method): res = getattr(controller, req.method)(env, start_response) else: - return get_err_response('InvalidURI')(env, start_response) + return get_err_response('MethodNotAllowed')(env, start_response) return res(env, start_response) diff --git a/swift3/test/unit/test_swift3.py b/swift3/test/unit/test_swift3.py index 1d2c6c17..81aae6a1 100644 --- a/swift3/test/unit/test_swift3.py +++ b/swift3/test/unit/test_swift3.py @@ -219,7 +219,7 @@ class TestSwift3(unittest.TestCase): dom = xml.dom.minidom.parseString("".join(resp)) self.assertEquals(dom.firstChild.nodeName, 'Error') code = dom.getElementsByTagName('Code')[0].childNodes[0].nodeValue - self.assertEquals(code, 'InvalidURI') + self.assertEquals(code, 'MethodNotAllowed') def _test_method_error(self, cl, method, path, status, headers={}): local_app = swift3.filter_factory({})(cl(status))