cloud_controller_ng
cloud_controller_ng copied to clipboard
Retry-After header in 429 Too Many Request responses should be time until rate limit reset
Issue
The Retry-After header should be time until reset rather than the current implementation of Unix time at which the rate limit reset
Context
The Mozilla docs cover this fairly well https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After. We currently just set the value to be the same as the X-RateLimit-Reset header value
Steps to Reproduce
- Query a CC API instance with a rate limit enabled
- Make enough requests to exhaust limit
- Look at headers on 429 response
Expected result
-
X-RateLimit-Resetheader contains timestamp at which limit resets -
Retry-Afterheader contains number of seconds until limit resets
Current result
-
X-RateLimit-Resetheader contains timestamp at which limit resets -
Retry-Afterheader contains timestamp at which limit resets
Possible Fix
Calculate the diff between the X-RateLimit-Reset and Time.now for the Retry-After header