py3: Make etag-quoter work

Previously, func tests (might?) complain like

   TypeError: 'dict_items' object does not support item assignment

Change-Id: Ic1a81f5b7262942ea52aa1de87cfcde25a2457ba
This commit is contained in:
Tim Burke 2020-04-21 11:43:52 -07:00
parent 72a6177520
commit e84d531b95
1 changed files with 5 additions and 5 deletions

View File

@ -105,11 +105,11 @@ class EtagQuoterMiddleware(object):
status, headers, resp_iter = req.call_application(self.app)
for i, (header, value) in enumerate(headers):
if header.lower() == 'etag':
if not value.startswith(('"', 'W/"')) or \
not value.endswith('"'):
headers[i] = (header, '"%s"' % value)
headers = [
(header, value) if header.lower() != 'etag' or (
value.startswith(('"', 'W/"')) and value.endswith('"'))
else (header, '"%s"' % value)
for header, value in headers]
start_response(status, headers)
return resp_iter