aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2014-08-20 17:29:43 +0100
committerTom Christie2014-08-20 17:29:43 +0100
commit3de09f1df04115f142f3e77360fae9810a14be6c (patch)
tree542447dc3b795df0b80b6b9669826c01a159e767 /rest_framework
parent6953a5ecec56d5eaffceef817316a742dcc2220c (diff)
parent3b07d0c9978335e183f369480618b48ff1e1b1ab (diff)
downloaddjango-rest-framework-3de09f1df04115f142f3e77360fae9810a14be6c.tar.bz2
Merge pull request #1508 from uploadcare/set-retry-after
set Retry-After header when throttled
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/exceptions.py2
-rw-r--r--rest_framework/views.py1
2 files changed, 2 insertions, 1 deletions
diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py
index 97dab77e..ad52d172 100644
--- a/rest_framework/exceptions.py
+++ b/rest_framework/exceptions.py
@@ -72,7 +72,7 @@ class UnsupportedMediaType(APIException):
class Throttled(APIException):
status_code = status.HTTP_429_TOO_MANY_REQUESTS
default_detail = 'Request was throttled.'
- extra_detail = "Expected available in %d second%s."
+ extra_detail = " Expected available in %d second%s."
def __init__(self, wait=None, detail=None):
if wait is None:
diff --git a/rest_framework/views.py b/rest_framework/views.py
index bca0aaef..23df3443 100644
--- a/rest_framework/views.py
+++ b/rest_framework/views.py
@@ -62,6 +62,7 @@ def exception_handler(exc):
headers['WWW-Authenticate'] = exc.auth_header
if getattr(exc, 'wait', None):
headers['X-Throttle-Wait-Seconds'] = '%d' % exc.wait
+ headers['Retry-After'] = '%d' % exc.wait
return Response({'detail': exc.detail},
status=exc.status_code,