mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +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,
|
||||
'anon': None,
|
||||
},
|
||||
'NUM_PROXIES': 0,
|
||||
'NUM_PROXIES': None,
|
||||
|
||||
# Pagination
|
||||
'PAGINATE_BY': None,
|
||||
|
|
|
@ -25,7 +25,7 @@ class BaseThrottle(object):
|
|||
"""
|
||||
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')
|
||||
|
||||
return xff.split(',')[-min(num_proxies, len(xff))].strip()
|
||||
|
@ -222,7 +222,6 @@ class ScopedRateThrottle(SimpleRateThrottle):
|
|||
# the `__init__` call.
|
||||
self.rate = self.get_rate()
|
||||
self.num_requests, self.duration = self.parse_rate(self.rate)
|
||||
|
||||
# We can now proceed as normal.
|
||||
return super(ScopedRateThrottle, self).allow_request(request, view)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user