ZF2-78: Http\Client throws RuntimeException when passed additional Encoding info.
Description
Zend\Http\Client can't rock Content-Type. in case of "application/x-www-form-urlencoded; charset=UTF-8"
$client = new \Zend\Http\Client;
$client->setUri('http://example.com');
$client->setHeaders(array(
//'Content-Type' => 'application/x-www-form-urlencoded' // Exception not throw
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' // throw RuntimeException
));
$client->setParameterPost(array('test' => 'foobar'));
$client->setMethod(\Zend\Http\Request::METHOD_POST);
$client->send();
(I met this error when upgrading Service\Akismet.. Akismet class uses setHeaders method as below.
'Content-Type' => 'application/x-www-form-urlencoded; charset=' . $this->getCharset()
Currently ZF1's Http_Client reset enctype at setMethod
$this->setEncType(self::ENC_URLENCODED);
So, I doubt as ZF1's lack of feature.. )
Comments
Posted by Kazusuke Sasezaki (sasezaki) on 2011-10-27T13:20:06.000+0000
patch is merged https://github.com/zendframework/zf2/pull/533