ZF-11030: Content-type set per default with PUT to '' has for consequence that Zend_Rest_Client PUT can't work


I am not able to successfully execute a PUT HTTP request via Zend_Rest_Client. I get the following error: Cannot handle content type '' automatically. Please use Zend_Http_Client::setRawData to send this kind of content.

The encoding type is in fact not set in such a request (while it is automatically set for POST request in Zend_HTTP_Client).

I made a small fix that I think is sufficient (line 358): if ($method == self::POST && $this->enctype === null) {

should be

if (($method == self::POST || $method == self::PUT) && $this->enctype === null) {


It's an issue between Zend_HTTP_Client and Zend_Rest_Client.

This issue has for consequence that the default use of Zend_Rest_Client PUT can't work.

I experience the same issue. Thanks for proposing a fix. I will create unit tests and fix this as soon as possible.

I added patches that add extensive testing. Allthough the proposed fix was good, I added support for DELETE as well.

PUT and DELETE were severely undertested, so the biggest patch is for the tests.

To support DELETE I also had to patch Zend_Http_Client_Adapter_Curl, that did not send the request body, hence no data.

I do not know if other adapters also fail to send DELETE data and I do not know if the curl adapter is the right one to fix if I want Zend_Rest_Client to send data with DELETE requests. However, I do know this fix is sufficient for the issue at hand.

I also know there is a failing test in the currently available tests for the curl client. That was there before I started and I communicated with Matthew WOP to make sure he is aware of this.

If no one complains about my patches for about a week, I will commit them and merge them back into the 1.11 branch.

set to patch, because now you can download two patches. The Curl patch will give you support for DELETE requests with data. Please note that in order for these to work with Zend_Rest_Client, we need to fix Zend_Rest_Client. It does not set the data on a DELETE request, but that is another issue.

Please not that the patch for the tests will have to be applied to tests/Zend/Http/Client directory. It contains a few new files and a patch for CommonHttpTests.php that is used by CurlTest.php, that itself did not need patching.

When this will be included in to ZF? In what version?

I will leave the issue open for review for about a week after submitting a patch. If within a week no-one has complained about the fix, I will commit it to trunk, and this case, merge it back into the 1.11 branch. So basically around july 26 2011 you should expect this to be in trunk.

Patches and tests look good. The only change I'd make is in the Client patch -- change the "or" comparison operators to "||".

Feel free to apply at will.

Committed to trunk with the "or" to "||" change. Client.php had to be merged with changes by Roman.

Today I patched the 1.11 branch with these changes, verified that the new tests pass and that no additional tests fail.

Linjene between basketball, skate>nike shox sko Og mote-orientert fottøy is uskarp with adidas Originals 'Hardland. Ankommer Originals forhandlere this month>shox sko is a brand new>nike shox colorway of the fasjonable Høy-top, kledd jeg premie falt hvitt skinn with sølv D-ring Blonder øjer and Signatur overdrevet Tunge.verdrevet Tunge.