only encode header keys as utf8 when not already bytes

This commit is contained in:
Thomas Steen Rasmussen 2017-04-19 23:05:25 +02:00
parent cc870105f1
commit 61454dafb5

View File

@ -33,7 +33,7 @@ def parse_x_forwarded_for(headers,
headers = {name.lower(): values for name, values in headers.items()} headers = {name.lower(): values for name, values in headers.items()}
else: else:
# Lowercase and encode header keys # Lowercase and encode header keys
headers = {name.lower().encode("utf-8"): values for name, values in headers.items()} headers = {name.lower() if isinstance(name, bytes) else name.lower().encode("utf-8"): values for name, values in headers.items()}
address_header_name = address_header_name.lower().encode("utf-8") address_header_name = address_header_name.lower().encode("utf-8")
result = original result = original