Zend Framework

allow query params with restDelete() queries

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.10.2
  • Fix Version/s: 1.11.10
  • Component/s: Zend_Rest_Client
  • Labels:
    None

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.

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

  1. Client.php.diff
    03/Mar/10 3:53 PM
    0.4 kB
    Remy Damour
  2. Rest-Client.php.patch
    23/Jul/11 5:51 PM
    2 kB
    Bart McLeod
  3. Rest-Client.php.patch
    21/Jul/11 9:42 AM
    1 kB
    Bart McLeod
  4. Rest-ClientTest.php.patch
    23/Jul/11 5:51 PM
    0.8 kB
    Bart McLeod

Activity

Hide
Remy Damour added a comment -

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

Show
Remy Damour added a comment - diff file against v1.10.2 allowing restDelete() to accept query arguments
Hide
Remy Damour added a comment -

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.

Show
Remy Damour added a comment - 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.
Hide
Bart McLeod added a comment -

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

Show
Bart McLeod added a comment - I am currently fixing this along with three other issues about Zend_Rest_Client. However, I use a different approach. See patch.
Hide
Bart McLeod added a comment -

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

Show
Bart McLeod added a comment - Added Rest-Client.php.patch. Is patch against current trunk, will work for branch 1.11
Hide
Bart McLeod added a comment -

New patch and patch for the unit test

Show
Bart McLeod added a comment - New patch and patch for the unit test
Hide
Bart McLeod added a comment -

Fix committed to trunk.

Show
Bart McLeod added a comment - Fix committed to trunk.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: