Issues

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

Issue Type: Improvement Created: 2010-03-03T15:51:41.000+0000 Last Updated: 2011-07-28T09:19:29.000+0000 Status: Resolved Fix version(s): - 1.11.10 (04/Aug/11)

Reporter: Remy Damour (remy215) Assignee: Bart McLeod (mcleod@spaceweb.nl) Tags: - Zend_Rest_Client

Related issues: Attachments: - Client.php.diff

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.

<pre class="highlight">

    /**
     * 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');
    }



<pre class="highlight">
    /**
     * 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

Posted by Remy Damour (remy215) on 2010-03-03T15:53:42.000+0000

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

Posted by Remy Damour (remy215) on 2010-03-03T16:16:09.000+0000

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.

Posted by Bart McLeod (mcleod@spaceweb.nl) on 2011-07-21T09:40:58.000+0000

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

Posted by Bart McLeod (mcleod@spaceweb.nl) on 2011-07-21T09:42:22.000+0000

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

Posted by Bart McLeod (mcleod@spaceweb.nl) on 2011-07-23T17:51:57.000+0000

New patch and patch for the unit test

Posted by Bart McLeod (mcleod@spaceweb.nl) on 2011-07-28T09:16:19.000+0000

Fix committed to trunk.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts