Fixed #86: Use left-most X-Forwarded-For value.

This commit is contained in:
Andrew Godwin 2017-02-16 10:01:07 -08:00
parent 80bacf1ea1
commit b8c96d7fb2
2 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,7 @@ class TestXForwardedForHttpParsing(TestCase):
}) })
self.assertEqual( self.assertEqual(
parse_x_forwarded_for(headers), parse_x_forwarded_for(headers),
['10.1.2.4', 0] ['10.1.2.3', 0]
) )
def test_original(self): def test_original(self):

View File

@ -37,7 +37,7 @@ def parse_x_forwarded_for(headers,
address_value = header_value(headers, address_header_name) address_value = header_value(headers, address_header_name)
if ',' in address_value: if ',' in address_value:
address_value = address_value.split(",")[-1].strip() address_value = address_value.split(",")[0].strip()
if ':' in address_value: if ':' in address_value:
address_host, address_port = address_value.split(':') address_host, address_port = address_value.split(':')