mirror of
https://github.com/django/daphne.git
synced 2024-11-13 11:36:34 +03:00
Enforce that header names and values are bytes
This commit is contained in:
parent
dd2c8b2a0f
commit
b3c097aabd
|
@ -45,6 +45,10 @@ def parse_x_forwarded_for(headers,
|
||||||
# Lowercase all header names in the dict
|
# Lowercase all header names in the dict
|
||||||
headers = {name.lower(): values for name, values in headers.items()}
|
headers = {name.lower(): values for name, values in headers.items()}
|
||||||
|
|
||||||
|
# Make sure header names and values are bytes
|
||||||
|
assert all(isinstance(name, bytes) for name in headers.keys())
|
||||||
|
assert all(isinstance(value, bytes) for value in headers.values())
|
||||||
|
|
||||||
address_header_name = address_header_name.lower().encode("utf-8")
|
address_header_name = address_header_name.lower().encode("utf-8")
|
||||||
result = original
|
result = original
|
||||||
if address_header_name in headers:
|
if address_header_name in headers:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user