Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
69fea562
Commit
69fea562
authored
Jan 12, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2401 from jpadilla/master
Fix ident format when using HTTP_X_FORWARDED_FOR
parents
e9ac1bb7
cc13ee05
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
8 deletions
+2
-8
rest_framework/throttling.py
+2
-8
No files found.
rest_framework/throttling.py
View file @
69fea562
...
@@ -32,10 +32,10 @@ class BaseThrottle(object):
...
@@ -32,10 +32,10 @@ class BaseThrottle(object):
if
num_proxies
==
0
or
xff
is
None
:
if
num_proxies
==
0
or
xff
is
None
:
return
remote_addr
return
remote_addr
addrs
=
xff
.
split
(
','
)
addrs
=
xff
.
split
(
','
)
client_addr
=
addrs
[
-
min
(
num_proxies
,
len
(
xff
))]
client_addr
=
addrs
[
-
min
(
num_proxies
,
len
(
addrs
))]
return
client_addr
.
strip
()
return
client_addr
.
strip
()
return
xff
if
xff
else
remote_addr
return
''
.
join
(
xff
.
split
())
if
xff
else
remote_addr
def
wait
(
self
):
def
wait
(
self
):
"""
"""
...
@@ -173,12 +173,6 @@ class AnonRateThrottle(SimpleRateThrottle):
...
@@ -173,12 +173,6 @@ class AnonRateThrottle(SimpleRateThrottle):
if
request
.
user
.
is_authenticated
():
if
request
.
user
.
is_authenticated
():
return
None
# Only throttle unauthenticated requests.
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
%
{
return
self
.
cache_format
%
{
'scope'
:
self
.
scope
,
'scope'
:
self
.
scope
,
'ident'
:
self
.
get_ident
(
request
)
'ident'
:
self
.
get_ident
(
request
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment