Skip to content
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

RESTful: Handle single field request with empty value #18

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open

RESTful: Handle single field request with empty value #18

weierophinney opened this issue Dec 31, 2019 · 1 comment
Labels
Bug Something isn't working

Comments

@weierophinney
Copy link
Member

Controller/AbstractRestfulController

There is no way to PUT/PATCH object with single field to empty value.

PUT /item/1
Content-Type: application/x-www-form-urlencoded

name=

Request payload is interpreted as string ($data = 'name=';) regardless Content-Type.
Proper value is $data = ['name' => ''];

I think ideally is split behaviour by Content-Type but that follows to huge BC. (see testCanReceiveStringAsRequestContent)

My pull request handle just one situation (example above) by header.


Originally posted by @autowp at zendframework/zend-mvc#251

@weierophinney weierophinney added the Bug Something isn't working label Dec 31, 2019
@weierophinney
Copy link
Member Author

@autowp I've made the change a bit more generic. It does not depend now on the content-type, as it was before. In case we have one element with empty value we are checking if the last character of the content is =. If so, then it is "correct" urlencoded content and we return array, as expected.
In case we have any string without = it will return this string, not an array.

In general I think it should be completely changed to work properly with the given content type correctly, as now this is quite hacky, imo.


Originally posted by @michalbundyra at zendframework/zend-mvc#251 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant