aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/throttling.py
diff options
context:
space:
mode:
authorXavier Ordoquy2014-06-23 14:02:45 +0200
committerXavier Ordoquy2014-06-23 14:02:45 +0200
commit2489e38a06f575aa144644eee683bd87f20186ef (patch)
treefc52fd2280d3ef6d0dc69d53a3771ee5f499ab29 /rest_framework/throttling.py
parent15c2c58b43a00ec29af99e0478b70eea57560fce (diff)
parente11f41ebc4ef088a5849771dfda5a7fba4f82904 (diff)
downloaddjango-rest-framework-2489e38a06f575aa144644eee683bd87f20186ef.tar.bz2
Merge remote-tracking branch 'origin/master' into 2.4.0
Conflicts: .travis.yml docs/api-guide/viewsets.md rest_framework/serializers.py rest_framework/throttling.py tests/test_generics.py tests/test_serializers.py tox.ini
Diffstat (limited to 'rest_framework/throttling.py')
-rw-r--r--rest_framework/throttling.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py
index fc24c92e..7e9f9d71 100644
--- a/rest_framework/throttling.py
+++ b/rest_framework/throttling.py
@@ -173,6 +173,12 @@ 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)