-
-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty body on custom operations #1282
Comments
It looks weird to me to not have a different behavior for custom and built in operations. What about this one: allow empty requests for a all operations IF Content-Type is not set? |
Only thing I know for sure is that sending an empty body on our operations should return a Now, there are users who may want to use empty contents (on POST/PUT operations). Forcing them to not use a |
At least, it should be consistent between |
I have to admit that from my point of view, it rings a bell 👍 |
Sorry, was thinking about this while reading bedtime stories, seems now totally irrelevant ;) |
I'm 👎 to allow empty bodies if the content-type is set to JSON or JSON-LD. An empty string is not a valid JSON document (you can try with https://jsonlint.com/) but the client is advertising that the payload is valid JSON. To me it should generate a 400. Validating the content-type is an OWASP best practice. |
Agree. Though I would 👍 very very much without a |
Wokay! I have to verify to be sure that PUT currently allow empty body while content-type is set, but if so, shouldn't it be the same for |
I don't think we allow it for PUT neither. |
It seems to be OK if there is no body and no content-type set: https://stackoverflow.com/a/29784642/1352334 |
@dunglas , I was assuming PUT was allowed to skip deserialization of empty content based on https://github.com/api-platform/core/blob/master/src/EventListener/DeserializeListener.php#L55 I may very well be missing something though, I am not very comfortable with the codebase yet :) |
Some facts I experiment with my setup (api-p v2.2.2): note: all requests have been made with
|
Ok we need to fix this inconsistency... |
To recap, should the expected behavior for POST|PUT be:
? Should this behavior be extended to GET|PATCH|DELETE ? While passing a body to a GET request is technically ok with the HTTP spec, it’s not recommended to do it. Still, the choice of passing GET body should be in the hands of the end user IMO. From elasticsearch (which does use body in GET request) doc:
https://www.elastic.co/guide/en/elasticsearch/guide/current/_empty_search.html |
See #2757 |
Ref: #1274 #782 and #805. #1786
The text was updated successfully, but these errors were encountered: