Merge "Allow EC to ignore invalid request ETag"

This commit is contained in:
Zuul 2018-10-11 08:07:35 +00:00 committed by Gerrit Code Review
commit 8e66d1278b
2 changed files with 15 additions and 10 deletions

View File

@ -2643,19 +2643,13 @@ class ECObjectController(BaseObjectController):
self.app.logger.increment('client_disconnects') self.app.logger.increment('client_disconnects')
raise HTTPClientDisconnect(request=req) 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 send_chunk('') # flush out any buffered data
computed_etag = (etag_hasher.hexdigest()
if etag_hasher else None)
footers = self._get_footers(req) footers = self._get_footers(req)
received_etag = footers.get( received_etag = footers.get('etag', req.headers.get(
'etag', '').strip('"') 'etag', '')).strip('"')
if (computed_etag and received_etag and if (computed_etag and received_etag and
computed_etag != received_etag): computed_etag != received_etag):
raise HTTPUnprocessableEntity(request=req) raise HTTPUnprocessableEntity(request=req)

View File

@ -4349,6 +4349,17 @@ class TestECObjControllerMimePutter(BaseObjectControllerMixin,
for conn in conns: for conn in conns:
self.assertTrue(conn.closed) 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 # make the footers callback send a bad Etag footer
footers_callback = make_footers_callback('not the test body') footers_callback = make_footers_callback('not the test body')
env = {'swift.callback.update_footers': footers_callback} env = {'swift.callback.update_footers': footers_callback}