mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +03:00
Default NUM_PROXIES to None instead of zero.
This commit is contained in:
parent
87e80b7be5
commit
900cb676e5
|
@ -63,7 +63,7 @@ DEFAULTS = {
|
||||||
'user': None,
|
'user': None,
|
||||||
'anon': None,
|
'anon': None,
|
||||||
},
|
},
|
||||||
'NUM_PROXIES': 0,
|
'NUM_PROXIES': None,
|
||||||
|
|
||||||
# Pagination
|
# Pagination
|
||||||
'PAGINATE_BY': None,
|
'PAGINATE_BY': None,
|
||||||
|
|
|
@ -25,7 +25,7 @@ class BaseThrottle(object):
|
||||||
"""
|
"""
|
||||||
num_proxies = api_settings.NUM_PROXIES
|
num_proxies = api_settings.NUM_PROXIES
|
||||||
|
|
||||||
if 'HTTP_X_FORWARDED_FOR' in request.META and num_proxies > 0:
|
if 'HTTP_X_FORWARDED_FOR' in request.META and num_proxies:
|
||||||
xff = request.META.get('HTTP_X_FORWARDED_FOR')
|
xff = request.META.get('HTTP_X_FORWARDED_FOR')
|
||||||
|
|
||||||
return xff.split(',')[-min(num_proxies, len(xff))].strip()
|
return xff.split(',')[-min(num_proxies, len(xff))].strip()
|
||||||
|
@ -222,7 +222,6 @@ class ScopedRateThrottle(SimpleRateThrottle):
|
||||||
# the `__init__` call.
|
# the `__init__` call.
|
||||||
self.rate = self.get_rate()
|
self.rate = self.get_rate()
|
||||||
self.num_requests, self.duration = self.parse_rate(self.rate)
|
self.num_requests, self.duration = self.parse_rate(self.rate)
|
||||||
|
|
||||||
# We can now proceed as normal.
|
# We can now proceed as normal.
|
||||||
return super(ScopedRateThrottle, self).allow_request(request, view)
|
return super(ScopedRateThrottle, self).allow_request(request, view)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user