Issues

ZF-9318: allow query params with restDelete() queries

Description

With current (v1.10.2) implementation of Zend_Rest_Client::restDelete(), you cannot add any query parameters to queried url.

For instance, if I want to delete item with id=1, I did not find how to end up with my-delete-url?id=1. This is very very very useful (not everybody use friendly urls / url-mapping|rewriting)

I slightly modified the function so that it behaves as restGet, restPost and restPut.



    /**
     * Performs an HTTP DELETE request to $path.
     *
     * @param string $path
     * @throws Zend_Http_Client_Exception
     * @return Zend_Http_Response
     */
    final public function restDelete($path)
    {
        $this->_prepareRest($path);
        return self::getHttpClient()->request('DELETE');
    }

    /**
     * Performs an HTTP DELETE request to $path.
     *
     * @param string $path
     * @param array  $query Array of GET parameters
     * @throws Zend_Http_Client_Exception
     * @return Zend_Http_Response
     */
    final public function restDelete($path, $query = null)
    {
        $this->_prepareRest($path);
    $client = self::getHttpClient();
    $client->setParameterGet($query);
        return $client->request('DELETE');
    }

Regards, Remy

Comments

diff file against v1.10.2 allowing restDelete() to accept query arguments

Note: current behaviour (not to provide arguments within queried url) seems to be inconsistent with current implementation of Zend_Client_Server.

When Zend_Client_Server is called through Zend_Rest_Client::restDelete() query, following error is returned: Unexpected error: No Method Specified.

It looks like Zend_Client_Server do expect ?method=xxx arg in queried url.

Proposed solution gets rid of this error.

I am currently fixing this along with three other issues about Zend_Rest_Client. However, I use a different approach. See patch.

Added Rest-Client.php.patch. Is patch against current trunk, will work for branch 1.11

New patch and patch for the unit test

Fix committed to trunk.