What HTTP response code should be used for an OPTION request?
Asked Answered
A

4

11

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?

Apiece answered 3/2, 2013 at 17:47 Comment(2)
Interestingly, Alan Dean’s HTTP headers status flow chart suggests 200.Alcoran
Nice catch.. Now go ahead and update MDN wikiWhortleberry
R
1

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

Resection answered 3/2, 2013 at 20:40 Comment(6)
this agrees with you. DELETE can be 200 OKMoist
Hiroto: I really don't care whether some other sources say the same. What's relevant is the specification.Resection
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).Inhambane
It's a statement of fact. You can easily verify it by looking at the actual HTTP specification (IETF RFC 7230...5).Resection
@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.Inhambane
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?Resection
C
7

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

Cita answered 23/1, 2016 at 20:16 Comment(0)
R
6

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.

Rakish answered 7/7, 2014 at 10:26 Comment(0)
R
1

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

Resection answered 3/2, 2013 at 20:40 Comment(6)
this agrees with you. DELETE can be 200 OKMoist
Hiroto: I really don't care whether some other sources say the same. What's relevant is the specification.Resection
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).Inhambane
It's a statement of fact. You can easily verify it by looking at the actual HTTP specification (IETF RFC 7230...5).Resection
@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.Inhambane
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?Resection
L
1

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

Lamented answered 30/1, 2014 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.