9

I noticed that the Mozilla HTTP response codes documentation states that

The methods PUT, DELETE, and OPTIONS can never result in a 200 OK response.

However it doesn't make clear what response should actually be used. My best guess would be 204:

204 : No Content

There is no content to send for this request, but the headers may be useful. The user-agent may update its cached headers for this resource with the new ones.

Can anyone comment as to whether or not this is the correct code to be using to response to an OPTIONS request?

CodesInChaos
  • 106,488
  • 23
  • 218
  • 262
Joshua
  • 6,320
  • 6
  • 45
  • 62

4 Answers4

7

I use 204 No Content because an OPTIONS response doesn't have any content.

cd1
  • 15,908
  • 12
  • 46
  • 47
5

The (updated, btw) RFCs for HTTP 1.1 clearly state 200 OK is an acceptable response for all 3 methods, see section 6.3.1 of RFC 7231.

Michael Foukarakis
  • 39,737
  • 6
  • 87
  • 123
1

RFC2616 clearly mentions a 200 response and requirements for a 200 response: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

Bryce
  • 8,313
  • 6
  • 55
  • 73
0

Well, in that case the Mozilla documentation is plainly wrong.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98
  • 1
    [this](http://books.google.de/books?id=XUaErakHsoAC&lpg=PP1&dq=restful%20web%20services&pg=PA197#v=onepage) agrees with you. `DELETE` can be `200 OK` – Amelia Feb 03 '13 at 20:44
  • Hiroto: I really don't care whether some other sources say the same. What's relevant is the specification. – Julian Reschke Feb 05 '13 at 09:17
  • 4
    How is this an answer? This looks to be a comment, not a answer. You stated no sources, you made no explanation. You simply told the OP that Mozilla was wrong without explaining why and without supplying sources (alternative documentation, specification, publications, SOMETHING). – Swivel Jan 24 '17 at 16:24
  • It's a statement of fact. You can easily verify it by looking at the *actual* HTTP specification (IETF RFC 7230...5). – Julian Reschke Jan 24 '17 at 19:08
  • @JulianReschke Highly unconstructive and unhelpful is all I'm saying. Maybe an explanation similar to Michael Foukarakis? Seeing as these answers are typically most helpful for their explanations and references, I found this to be quite uninformative and, quite frankly, useless. I don't think I've seen an Answer on SO worse than this one; especially given that it was the accepted response. – Swivel Jan 30 '17 at 03:06
  • Again, it's a statement of fact, and last time I checked, this text was removed from the Mozilla documentation. Can we please move on? – Julian Reschke Jan 30 '17 at 10:47