diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index 5c6948c242..bdd044eac5 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -2643,19 +2643,13 @@ class ECObjectController(BaseObjectController): self.app.logger.increment('client_disconnects') raise HTTPClientDisconnect(request=req) - computed_etag = (etag_hasher.hexdigest() - if etag_hasher else None) - received_etag = req.headers.get( - 'etag', '').strip('"') - if (computed_etag and received_etag and - computed_etag != received_etag): - raise HTTPUnprocessableEntity(request=req) - send_chunk('') # flush out any buffered data + computed_etag = (etag_hasher.hexdigest() + if etag_hasher else None) footers = self._get_footers(req) - received_etag = footers.get( - 'etag', '').strip('"') + received_etag = footers.get('etag', req.headers.get( + 'etag', '')).strip('"') if (computed_etag and received_etag and computed_etag != received_etag): raise HTTPUnprocessableEntity(request=req) diff --git a/test/unit/proxy/controllers/test_obj.py b/test/unit/proxy/controllers/test_obj.py index 78b2e95aa8..25dbc44b64 100644 --- a/test/unit/proxy/controllers/test_obj.py +++ b/test/unit/proxy/controllers/test_obj.py @@ -4349,6 +4349,17 @@ class TestECObjControllerMimePutter(BaseObjectControllerMixin, for conn in conns: self.assertTrue(conn.closed) + # make the footers callback send the correct etag + footers_callback = make_footers_callback(test_body) + env = {'swift.callback.update_footers': footers_callback} + headers = {'Etag': 'bad etag'} + req = swift.common.swob.Request.blank( + '/v1/a/c/o', method='PUT', headers=headers, environ=env, + body=test_body) + with set_http_connect(*codes, expect_headers=self.expect_headers): + resp = req.get_response(self.app) + self.assertEqual(201, resp.status_int) + # make the footers callback send a bad Etag footer footers_callback = make_footers_callback('not the test body') env = {'swift.callback.update_footers': footers_callback}