سؤال

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?

هل كانت مفيدة؟

المحلول 2

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

نصائح أخرى

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

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.

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top