3

Should an OPTIONS request ever return a 429?

The problem is really that a Browser client (js) can not detect the 429 correctly when returned from an OPTIONS request. So I'm leaning towards only returning 429 for non OPTIONS requests.

What is best practise here?

vincent
  • 1,953
  • 3
  • 18
  • 24
  • 1
    Nothing in the HTTP spec forbids returning 429 from an OPTIONS request. –  May 21 '17 at 02:05
  • 2
    The question is legitimate: browsers may not handle well error codes on OPTIONS requests even if such codes are allowed by the spec. – DS. May 21 '17 at 03:02

1 Answers1

1

OPTIONS is a Preflight request. Typically the response is static with just a few headers. So sending the real response is no more strain on the server than responding with 429 (Too Many Requests). If browsers have trouble with it, it would make sense to always send the real response for OPTIONS, and let the immediately-following actual request get the error.

DS.
  • 22,632
  • 6
  • 47
  • 54
  • `Typically the response is static with just a few headers.` - I did not know that. It makes a lot of sense though. I'll remove the 429 logic from the `OPTIONS` request. Accepted! – vincent May 21 '17 at 17:49