httpbin icon indicating copy to clipboard operation
httpbin copied to clipboard

Consider Adding a 429 Response

Open jkmassel opened this issue 8 years ago • 5 comments

It'd be great to be able to use this service to simulate 429 TOO MANY REQUESTS errors, in a format like this: https://httpstatuses.com/429.

Could do something like /too-many-requests/:number where :number is the number of seconds to put in the retry-after header. If it's agreed that this is a good feature to have, I'd be willing to put together a pull request.

Thanks for considering!

jkmassel avatar Dec 17 '17 20:12 jkmassel

you can use http://httpbin.org/status/429 already no ?

ldemailly avatar Dec 19 '17 04:12 ldemailly

Yes, but it doesn't populate a Retry-After header (per https://tools.ietf.org/html/rfc6585#section-4) or X-RateLimit-Limit/X-RateLimit-Remaining/X-RateLimit-Reset headers, so it's difficult to use it in place of a properly rate limited API.

This could be a special case on the 429 code where it populates these headers as well, that would make lots of sense, too!

jkmassel avatar Dec 20 '17 21:12 jkmassel

What’s really needed is a way to combine multiple endpoints. All you need for this special case is a combination of the existing status and response-headers endpoints.

runeksvendsen avatar Oct 11 '19 09:10 runeksvendsen

Yes, it's duplicate of more general #612

xmedeko avatar Oct 19 '21 08:10 xmedeko

(shamless plug) note you can do that with fortio :p

$ curl -v "localhost:8080/?status=429&header=Retry-After:60"
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /?status=429&header=Retry-After:60 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 429 Too Many Requests
< Retry-After: 60
< Date: Wed, 20 Oct 2021 18:24:15 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact
* Closing connection 0

https://github.com/fortio/fortio#server-urls-and-features

ldemailly avatar Oct 20 '21 18:10 ldemailly