zend-http icon indicating copy to clipboard operation
zend-http copied to clipboard

ChunkedBody decoding with Curl Adapter

Open necromant2005 opened this issue 9 years ago • 7 comments

Zend\Http\Response::decodeChunkedBody fail with exception when curl adapter decode body itself , BUT it still has "Transfer-Encoding: encoded" header

$client = new \Zend\Http\Client();
$client->setOptions(array( 
   'sslverifypeer' => false,
   'adapter'         => 'Zend\Http\Client\Adapter\Curl',
));
$client->setUri('https://www.truesocialmetrics.com/');
$response = $client->send(); // Error parsing body - doesn't seem to be a chunked message

php: 5.5 , 5.6, 7

necromant2005 avatar Aug 27 '15 07:08 necromant2005

It looks like you're leaving off the $response->getBody() call that would actually cause the exception.

At any rate, in this case, it looks like the problem is that the server you're talking to sends the header in lowercase: transfer-encoding: chunked, while the code in the curl adapter that's supposed to deal with this (line 437) only looks for the uppercase version.

Header names are case-insensitive by definition, and the values for Transfer-Encoding are also case-insensitive, so just adding the i case-insensitivity flag to the regex being used here is probably a reasonable solution.

zerocrates avatar Sep 14 '15 18:09 zerocrates

This would be fixed by the open PR #10, and this issue serves as an example of the kind of bug that currently happens and that PR would fix.

Specifically, this looks like a regression introduced by ddf5a83c60120450cc15467a886192de4f2c229f: the comparisons were case-sensitive at that point, and when adding support for varying whitespace, the insensitivity was accidentally not applied to the new regex version of the code.

zerocrates avatar Sep 14 '15 18:09 zerocrates

Any idea when this would be fixed?

sgehrig avatar May 03 '16 14:05 sgehrig

Nope. I've patched zend to solve this issue.

necromant2005 avatar May 03 '16 14:05 necromant2005

Who is the current maintainer of Zend\Http?

sgehrig avatar May 03 '16 14:05 sgehrig

I suppose that's @weierophinney

necromant2005 avatar May 03 '16 15:05 necromant2005

This repository has been closed and moved to laminas/laminas-http; a new issue has been opened at https://github.com/laminas/laminas-http/issues/25.

weierophinney avatar Dec 31 '19 22:12 weierophinney