Do not use redundant attr check for keys in fold_headers

We only care about items, so use it, and pass if we get an
AttributeError

Change-Id: I7a09b63db390431be044ae3fc6aeece565606b40
Closes-Bug: #1756157
This commit is contained in:
Chris Dent 2018-03-20 13:48:05 +00:00
parent 4b87196837
commit e93d35f10d
1 changed files with 3 additions and 1 deletions

View File

@ -117,8 +117,10 @@ def fold_headers(headers):
"""Turn a list of headers into a folded dict."""
# If it behaves like a dict, return it. Webob uses objects which
# are not dicts, but behave like them.
if hasattr(headers, 'keys'):
try:
return dict((k.lower(), v) for k, v in headers.items())
except AttributeError:
pass
header_dict = collections.defaultdict(list)
for header, value in headers:
header_dict[header.lower()].append(value.strip())