aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/throttling.py
diff options
context:
space:
mode:
authorTom Christie2015-01-19 15:23:08 +0000
committerTom Christie2015-01-19 15:23:08 +0000
commite5b94f7b7bbf2f6f35c5e33fb2723bdb0d33bad3 (patch)
treea156a4a29a26540c52e5580ffa555b14d6c63fbe /rest_framework/throttling.py
parentdbb684117f6fe0f9c34f98d5e914fc106090cdbc (diff)
parent3cc39ffbceffc5fdbb511d9a10e7732329e8baa4 (diff)
downloaddjango-rest-framework-e5b94f7b7bbf2f6f35c5e33fb2723bdb0d33bad3.tar.bz2
Merge branch 'version-3.1' into cursor-pagination
Diffstat (limited to 'rest_framework/throttling.py')
-rw-r--r--rest_framework/throttling.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py
index 361dbddf..0f10136d 100644
--- a/rest_framework/throttling.py
+++ b/rest_framework/throttling.py
@@ -32,10 +32,10 @@ class BaseThrottle(object):
if num_proxies == 0 or xff is None:
return remote_addr
addrs = xff.split(',')
- client_addr = addrs[-min(num_proxies, len(xff))]
+ client_addr = addrs[-min(num_proxies, len(addrs))]
return client_addr.strip()
- return xff if xff else remote_addr
+ return ''.join(xff.split()) if xff else remote_addr
def wait(self):
"""
@@ -173,12 +173,6 @@ class AnonRateThrottle(SimpleRateThrottle):
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)