Merge "Too many if clauses in the _clean_incoming_headers and the _clean_outgoing_headers routines of the tempurl module"

This commit is contained in:
Jenkins 2014-09-10 01:18:41 +00:00 committed by Gerrit Code Review
commit 4f16239280

View File

@ -464,22 +464,19 @@ class TempURL(object):
:param env: The WSGI environment for the request. :param env: The WSGI environment for the request.
""" """
for h in env.keys(): for h in env.keys():
remove = h in self.incoming_remove_headers
if not remove:
for p in self.incoming_remove_headers_startswith:
if h.startswith(p):
remove = True
break
if remove:
if h in self.incoming_allow_headers: if h in self.incoming_allow_headers:
remove = False continue
if remove:
for p in self.incoming_allow_headers_startswith: for p in self.incoming_allow_headers_startswith:
if h.startswith(p): if h.startswith(p):
remove = False
break break
if remove: else:
if h in self.incoming_remove_headers:
del env[h] del env[h]
continue
for p in self.incoming_remove_headers_startswith:
if h.startswith(p):
del env[h]
break
def _clean_outgoing_headers(self, headers): def _clean_outgoing_headers(self, headers):
""" """
@ -495,22 +492,19 @@ class TempURL(object):
""" """
headers = HeaderKeyDict(headers) headers = HeaderKeyDict(headers)
for h in headers.keys(): for h in headers.keys():
remove = h in self.outgoing_remove_headers
if not remove:
for p in self.outgoing_remove_headers_startswith:
if h.startswith(p):
remove = True
break
if remove:
if h in self.outgoing_allow_headers: if h in self.outgoing_allow_headers:
remove = False continue
if remove:
for p in self.outgoing_allow_headers_startswith: for p in self.outgoing_allow_headers_startswith:
if h.startswith(p): if h.startswith(p):
remove = False
break break
if remove: else:
if h in self.outgoing_remove_headers:
del headers[h] del headers[h]
continue
for p in self.outgoing_remove_headers_startswith:
if h.startswith(p):
del headers[h]
break
return headers.items() return headers.items()