From d3fdeb7eda7ed941cca02079f142776ef84a3b48 Mon Sep 17 00:00:00 2001 From: Fabien Millerand Date: Mon, 21 Aug 2017 22:35:03 +0200 Subject: [PATCH] Fix value error --- daphne/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daphne/utils.py b/daphne/utils.py index dd5eb6b..cfe3bb0 100644 --- a/daphne/utils.py +++ b/daphne/utils.py @@ -4,7 +4,7 @@ from twisted.web.http_headers import Headers def header_value(headers, header_name): value = headers[header_name] if isinstance(value, list): - value = value[0] + value = value[-1] return value.decode("utf-8") @@ -37,7 +37,7 @@ def parse_x_forwarded_for(headers, address_value = header_value(headers, address_header_name) if ',' in address_value: - address_value = address_value.split(",")[-1].strip() + address_value = address_value.split(",")[0].strip() result = [address_value, 0]