Merge "Fix best response to return correct status"
This commit is contained in:
commit
f90fe4fb3d
@ -49,7 +49,7 @@ from swift.common.http import is_informational, is_success, is_redirection, \
|
|||||||
HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVICE_UNAVAILABLE, \
|
HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVICE_UNAVAILABLE, \
|
||||||
HTTP_INSUFFICIENT_STORAGE, HTTP_UNAUTHORIZED, HTTP_CONTINUE
|
HTTP_INSUFFICIENT_STORAGE, HTTP_UNAUTHORIZED, HTTP_CONTINUE
|
||||||
from swift.common.swob import Request, Response, HeaderKeyDict, Range, \
|
from swift.common.swob import Request, Response, HeaderKeyDict, Range, \
|
||||||
HTTPException, HTTPRequestedRangeNotSatisfiable
|
HTTPException, HTTPRequestedRangeNotSatisfiable, HTTPServiceUnavailable
|
||||||
from swift.common.request_helpers import strip_sys_meta_prefix, \
|
from swift.common.request_helpers import strip_sys_meta_prefix, \
|
||||||
strip_user_meta_prefix, is_user_meta, is_sys_meta, is_sys_or_user_meta
|
strip_user_meta_prefix, is_user_meta, is_sys_meta, is_sys_or_user_meta
|
||||||
from swift.common.storage_policy import POLICIES
|
from swift.common.storage_policy import POLICIES
|
||||||
@ -1256,10 +1256,9 @@ class Controller(object):
|
|||||||
quorum_size=quorum_size)
|
quorum_size=quorum_size)
|
||||||
|
|
||||||
if not resp:
|
if not resp:
|
||||||
resp = Response(request=req)
|
resp = HTTPServiceUnavailable(request=req)
|
||||||
self.app.logger.error(_('%(type)s returning 503 for %(statuses)s'),
|
self.app.logger.error(_('%(type)s returning 503 for %(statuses)s'),
|
||||||
{'type': server_type, 'statuses': statuses})
|
{'type': server_type, 'statuses': statuses})
|
||||||
resp.status = '503 Internal Server Error'
|
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ class TestFuncs(unittest.TestCase):
|
|||||||
overrides = {302: 204, 100: 204}
|
overrides = {302: 204, 100: 204}
|
||||||
resp = base.best_response(req, statuses, reasons, bodies, server_type,
|
resp = base.best_response(req, statuses, reasons, bodies, server_type,
|
||||||
headers=headers, overrides=overrides)
|
headers=headers, overrides=overrides)
|
||||||
self.assertEqual(resp.status, '503 Internal Server Error')
|
self.assertEqual(resp.status, '503 Service Unavailable')
|
||||||
|
|
||||||
# next make a 404 quorum and make sure the last delete (real) 404
|
# next make a 404 quorum and make sure the last delete (real) 404
|
||||||
# status is the one returned.
|
# status is the one returned.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user