Skip to content
Merged
Changes from 1 commit
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
8 changes: 1 addition & 7 deletions rest_framework/throttling.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_ident(self, request):
client_addr = addrs[-min(num_proxies, len(xff))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #2400 (comment), this should be len(addrs) instead of len(xff).

return client_addr.strip()

return xff if xff else remote_addr
return ''.join(xff.split()) if xff else remote_addr

def wait(self):
"""
Expand Down Expand Up @@ -173,12 +173,6 @@ def get_cache_key(self, request, view):
if request.user.is_authenticated():
return None # Only throttle unauthenticated requests.

ident = request.META.get('HTTP_X_FORWARDED_FOR')
if ident is None:
ident = request.META.get('REMOTE_ADDR')
else:
ident = ''.join(ident.split())

return self.cache_format % {
'scope': self.scope,
'ident': self.get_ident(request)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xordoquy note here we weren't using the ident variable

Expand Down