Verified Commit e5ad0d15 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Renamed X-RateLimit-Available-At to Retry-After and removed X-RateLimit-Available header

parent c2d01e9d
Pipeline #5572 passed with stages
in 3 minutes and 35 seconds
......@@ -234,8 +234,7 @@ class ThrottleStatusMiddleware:
# At this point, the client can send additional requests
oldtest_request = throttle_status["history"][-1]
remaining = throttle_status["duration"] - (now - int(oldtest_request))
response["X-RateLimit-Available"] = str(now + remaining)
response["X-RateLimit-AvailableSeconds"] = str(remaining)
response["Retry-After"] = str(remaining)
# At this point, all Rate Limit is reset to 0
latest_request = throttle_status["history"][0]
remaining = throttle_status["duration"] - (now - int(latest_request))
......
......@@ -215,8 +215,7 @@ def test_throttle_status_middleware_includes_info_in_response_headers(mocker):
assert response["X-RateLimit-Scope"] == "hello"
assert response["X-RateLimit-Reset"] == str(int(time.time()) + 2000)
assert response["X-RateLimit-ResetSeconds"] == str(2000)
assert response["X-RateLimit-Available"] == str(int(time.time()) + 1800)
assert response["X-RateLimit-AvailableSeconds"] == str(1800)
assert response["Retry-After"] == str(1800)
def test_throttle_status_middleware_returns_proper_response(mocker):
......
......@@ -88,12 +88,7 @@ info:
<td>How many requests can be sent with the same scope before the limit applies</td>
</tr>
<tr>
<td><code>X-RateLimit-Available</code> (if <code>X-RateLimit-Remaining</code> is 0)</td>
<td>1568126189</td>
<td>A timestamp indicating when the client can retry</td>
</tr>
<tr>
<td><code>X-RateLimit-AvailableSeconds</code> (if <code>X-RateLimit-Remaining</code> is 0)</td>
<td><code>Retry-After</code> (if <code>X-RateLimit-Remaining</code> is 0)</td>
<td>3543</td>
<td>How many seconds to wait before a retry</td>
</tr>
......
......@@ -100,8 +100,7 @@ axios.interceptors.response.use(function (response) {
scope: error.response.headers['x-ratelimit-scope'],
remaining: error.response.headers['x-ratelimit-remaining'],
duration: error.response.headers['x-ratelimit-duration'],
available: error.response.headers['x-ratelimit-available'],
availableSeconds: error.response.headers['x-ratelimit-availableseconds'],
availableSeconds: error.response.headers['retry-after'],
reset: error.response.headers['x-ratelimit-reset'],
resetSeconds: error.response.headers['x-ratelimit-resetseconds'],
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment