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

View File

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