Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

DELETE method can not have an input_filter #60

Open
BreiteSeite opened this issue Sep 29, 2015 · 4 comments
Open

DELETE method can not have an input_filter #60

BreiteSeite opened this issue Sep 29, 2015 · 4 comments

Comments

@BreiteSeite
Copy link
Contributor

Because of ContentValidationListener.php:63 it is not possible to validate the body of a DELETE request (contrary to the README.md).

IMHO the implementation is wrong, DELETEcan have a body according to RFC 7231, so DELETE should be removed from ContentValidationListener::methodsWithoutBodies.

@PioneerGeek
Copy link

@BreiteSeite 👍🏻 for the above. DELETE usually only requires a request body when removing many entries at once from a list (for a collection). So, based on that, something similar to the following could be added to the content validation listener (ContentValidationListener) in the function onRoute(MvcEvent $e):

...
if (in_array($method, $this->methodsWithoutBodies)) {
    if ($method === 'DELETE') {
        if (isset($this->restControllers[$controllerService])) {
            $identifierName = $this->restControllers[$controllerService];
        } else {
            $identifierName = 'id';
        }

        if ($routeMatches->getParam($identifierName)) {
            return;
        }
    } else {
        return;
    }
}
...

@weierophinney
Copy link
Member

Now that we have support for GET requests to provide an input filter for collections, we can likely do this for DELETE. I'm marking this as an enhancement, and soliciting help for resolving it; it should be relatively easy to accomplish.

@tigran-m-dev
Copy link

@weierophinney I think you could close this issue as in version 1.6.0 DELETE request already supported body (it is removed from ContentValidationListener::methodsWithoutBodies) and implemented that functionality

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas-api-tools/api-tools-content-validation; a new issue has been opened at laminas-api-tools/api-tools-content-validation#5.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants