FOSRestBundle icon indicating copy to clipboard operation
FOSRestBundle copied to clipboard

No content for OPTIONS requests

Open hpatoio opened this issue 6 years ago • 2 comments

I've an action that responds to OPTIONS verb. I don't get any error but the response is always a 200 with no content.

If I change my code to respond to GET I receive the correct data in the response.

Is this a desired behavior ? Can OPTIONS return data ?

hpatoio avatar Mar 22 '18 08:03 hpatoio

I guess this is answer you are looking for: https://stackoverflow.com/a/47602072/1565786

stloyd avatar Mar 22 '18 10:03 stloyd

AFAIK OPTIONS requests can return data in the body

The response body, if any, SHOULD also include information about the communication options. The format for such a body is not defined by this specification, but might be defined by future extensions to HTTP. Content negotiation MAY be used to select the appropriate response format. If no response body is included, the response MUST include a Content-Length field with a field-value of "0".

Taken from: https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

My question was probably not clear. It was not:

Is it correct to have data in the response from a request that use OPTIONS

but

Does this bundle have some special handling for requests that use OPTIONS that force the body to be empty ?

hpatoio avatar Mar 22 '18 10:03 hpatoio