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

Issue Type: Patch Created: 2011-02-03T11:47:46.000+0000 Last Updated: 2012-11-21T08:06:52.000+0000 Status: Resolved Fix version(s): - 1.11.10 (04/Aug/11)

Reporter: Jawad (jawadstouli) Assignee: Bart McLeod ( Tags: - Zend_Http_Client

  • Zend_Rest_Client

Related issues: - ZF-10162

Attachments: - Client-apply-to-test-Zend_Http_Client-directory.patch


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) {


Posted by Grégory Eve (igreg) on 2011-03-17T11:23:08.000+0000

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.

Posted by Bart McLeod ( on 2011-07-11T10:38:39.000+0000

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

Posted by Bart McLeod ( on 2011-07-19T21:44:49.000+0000

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.

Posted by Bart McLeod ( on 2011-07-19T21:47:08.000+0000

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.

Posted by Bart McLeod ( on 2011-07-19T21:51:39.000+0000

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.

Posted by Sergey Romanov (serhioromano) on 2011-07-21T11:00:01.000+0000

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

Posted by Bart McLeod ( on 2011-07-21T12:08:17.000+0000

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.

Posted by Matthew Weier O'Phinney (matthew) on 2011-07-25T19:05:20.000+0000

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.

Posted by Bart McLeod ( on 2011-07-26T20:00:19.000+0000

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

Posted by Bart McLeod ( on 2011-07-27T21:13:50.000+0000

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

Posted by nike shox (nike shox) on 2012-11-21T08:06:52.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 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.