diff options
Diffstat (limited to 'rest_framework/throttling.py')
| -rw-r--r-- | rest_framework/throttling.py | 6 |
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) |
