mirror of
https://github.com/django/daphne.git
synced 2025-07-06 21:03:04 +03:00
Fix broken proxy util code
This commit is contained in:
parent
7d1123d39a
commit
ecf88ee72a
|
@ -27,7 +27,7 @@ def parse_x_forwarded_for(headers,
|
||||||
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:
|
||||||
address_value = headers[address_header_name].decode("utf-8")
|
address_value = headers[address_header_name][0].decode("utf-8")
|
||||||
|
|
||||||
if ',' in address_value:
|
if ',' in address_value:
|
||||||
address_value = address_value.split(",")[-1].strip()
|
address_value = address_value.split(",")[-1].strip()
|
||||||
|
@ -46,8 +46,8 @@ def parse_x_forwarded_for(headers,
|
||||||
# We only want to parse the X-Forwarded-Port header if we also parsed the X-Forwarded-For
|
# We only want to parse the X-Forwarded-Port header if we also parsed the X-Forwarded-For
|
||||||
# header to avoid inconsistent results.
|
# header to avoid inconsistent results.
|
||||||
port_header_name = port_header_name.lower().encode("utf-8")
|
port_header_name = port_header_name.lower().encode("utf-8")
|
||||||
if headers.hasHeader(port_header_name):
|
if port_header_name in headers:
|
||||||
port_value = headers.getRawHeaders(port_header_name)[0].decode("utf-8")
|
port_value = headers[port_header_name][0].decode("utf-8")
|
||||||
try:
|
try:
|
||||||
result[1] = int(port_value)
|
result[1] = int(port_value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user