Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop unused function parse_remote_addr() #708

Merged
merged 1 commit into from
Dec 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,34 +208,6 @@ def guess_filename(obj, default=None):
return default


def parse_remote_addr(forward):
if isinstance(forward, str):
# we only took the last one
# http://en.wikipedia.org/wiki/X-Forwarded-For
if ',' in forward:
forward = forward.rsplit(',', 1)[-1].strip()

# find host and port on ipv6 address
if '[' in forward and ']' in forward:
host = forward.split(']')[0][1:].lower()
elif ':' in forward and forward.count(':') == 1:
host = forward.split(':')[0].lower()
else:
host = forward

forward = forward.split(']')[-1]
if ':' in forward and forward.count(':') == 1:
port = forward.split(':', 1)[1]
else:
port = 80

remote = (host, port)
else:
remote = forward

return remote[0], str(remote[1])


class AccessLogger:
"""Helper object to log access.

Expand Down