Issues

ZF-12490: Error "Error parsing body - doesn't seem to be a chunked message" due to transfer encoding management in Zend\Http\Client\Adapter\Socket

Description

This issue affect Zend 2 but I can't create an issue on that project.

Chunked tranfer encoding is managed by Zend\Http\Client\Response in getBody function. But the underlined adapter can also manage this transfer encoding. For instance, Zend\Http\Client\Adapter\Curl manage it so a little piece of code remove the "Transfer-Encoding" header. Zend\Http\Client\Adapter\Socket manage also this transfer encoding but without removing the header. So Zend\Http\Client\Response fail decode body because it is already decoded.

Please copy the following code from Zend\Http\Client\Adapter\Curl to Zend\Http\Client\Adapter\Socket: // cURL automatically decodes chunked-messages, this means we have to disallow the Zend\Http\Response to do it again if (stripos($this->response, "Transfer-Encoding: chunked\r\n")) { $this->response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $this->response); }

It can also be interesting to add a "Content-Length" header to the response once the data is decoded (so in Socket and in Curl class).

Comments

For ZF2 please use the issue tracker on Github.