diff options
| author | Tom Christie | 2013-12-13 00:02:18 +0000 |
|---|---|---|
| committer | Tom Christie | 2013-12-13 00:02:18 +0000 |
| commit | 83da4949c099fcf7e7636c98b9052b502e1bf74b (patch) | |
| tree | 2bfd7d7d10268b7cdf15c48612dfa2dc8904f865 /rest_framework/throttling.py | |
| parent | d6d4621c4580ae4902fc895bdca78aced0ec7eab (diff) | |
| download | django-rest-framework-83da4949c099fcf7e7636c98b9052b502e1bf74b.tar.bz2 | |
Allow NUM_PROXIES=0 and include more docs
Diffstat (limited to 'rest_framework/throttling.py')
| -rw-r--r-- | rest_framework/throttling.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py index 60e46d47..c40f3065 100644 --- a/rest_framework/throttling.py +++ b/rest_framework/throttling.py @@ -28,8 +28,12 @@ class BaseThrottle(object): remote_addr = request.META.get('REMOTE_ADDR') num_proxies = api_settings.NUM_PROXIES - if xff and num_proxies: - return xff.split(',')[-min(num_proxies, len(xff))].strip() + if num_proxies is not None: + if num_proxies == 0 or xff is None: + return remote_addr + addrs = xff.split(',') + client_addr = addrs[-min(num_proxies, len(xff))] + return client_addr.strip() return xff if xff else remote_addr |
