diff options
Diffstat (limited to 'swift')
-rw-r--r-- | swift/common/swob.py | 2 | ||||
-rw-r--r-- | swift/proxy/controllers/obj.py | 20 |
2 files changed, 15 insertions, 7 deletions
diff --git a/swift/common/swob.py b/swift/common/swob.py index fdcbaf3e9..e6b3d4294 100644 --- a/swift/common/swob.py +++ b/swift/common/swob.py @@ -1331,7 +1331,7 @@ class Response(object): object length and body or app_iter to reset the content_length properties on the request. - It is ok to not call this method, the conditional resposne will be + It is ok to not call this method, the conditional response will be maintained for you when you __call__ the response. """ self.response_iter = self._response_iter(self.app_iter, self._body) diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index bdb2028f3..e6e3982f8 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -56,9 +56,10 @@ from swift.common.exceptions import ChunkReadTimeout, \ PutterConnectError, ChunkReadError from swift.common.http import ( is_informational, is_success, is_client_error, is_server_error, - HTTP_CONTINUE, HTTP_CREATED, HTTP_MULTIPLE_CHOICES, + is_redirection, HTTP_CONTINUE, HTTP_CREATED, HTTP_MULTIPLE_CHOICES, HTTP_INTERNAL_SERVER_ERROR, HTTP_SERVICE_UNAVAILABLE, - HTTP_INSUFFICIENT_STORAGE, HTTP_PRECONDITION_FAILED, HTTP_CONFLICT) + HTTP_INSUFFICIENT_STORAGE, HTTP_PRECONDITION_FAILED, HTTP_CONFLICT, + HTTP_REQUESTED_RANGE_NOT_SATISFIABLE) from swift.common.storage_policy import (POLICIES, REPL_POLICY, EC_POLICY, ECDriverError, PolicyError) from swift.proxy.controllers.base import Controller, delay_denial, \ @@ -2040,7 +2041,12 @@ class ECObjectController(BaseObjectController): headers=resp_headers, conditional_response=True, app_iter=app_iter) - app_iter.kickoff(req, resp) + try: + app_iter.kickoff(req, resp) + except HTTPException as err_resp: + # catch any HTTPException response here so that we can + # process response headers uniformly in _fix_response + resp = err_resp else: statuses = [] reasons = [] @@ -2060,10 +2066,12 @@ class ECObjectController(BaseObjectController): def _fix_response(self, resp): # EC fragment archives each have different bytes, hence different # etags. However, they all have the original object's etag stored in - # sysmeta, so we copy that here so the client gets it. + # sysmeta, so we copy that here (if it exists) so the client gets it. + resp.headers['Etag'] = resp.headers.get('X-Object-Sysmeta-Ec-Etag') + if (is_success(resp.status_int) or is_redirection(resp.status_int) or + resp.status_int == HTTP_REQUESTED_RANGE_NOT_SATISFIABLE): + resp.accept_ranges = 'bytes' if is_success(resp.status_int): - resp.headers['Etag'] = resp.headers.get( - 'X-Object-Sysmeta-Ec-Etag') resp.headers['Content-Length'] = resp.headers.get( 'X-Object-Sysmeta-Ec-Content-Length') resp.fix_conditional_response() |