aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2015-01-12 12:20:47 +0000
committerTom Christie2015-01-12 12:20:47 +0000
commit69fea562456761c98ed3c58d14aa3e236a653efc (patch)
treebbf8f0488945a6d8105c156d962cd0c6e400afd8 /rest_framework
parente9ac1bb78add68635e7f0881c16d2a3ddda2f1b5 (diff)
parentcc13ee0577fb3de9602da634ab9c835749da49c4 (diff)
downloaddjango-rest-framework-69fea562456761c98ed3c58d14aa3e236a653efc.tar.bz2
Merge pull request #2401 from jpadilla/master
Fix ident format when using HTTP_X_FORWARDED_FOR
Diffstat (limited to 'rest_framework')
-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)