Issues

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