Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Http Client with Curl / default adapter and transfer-encoding chunked: Error parsing body - doesn't seem to be a chunked message #7683

Closed
lucian303 opened this issue Mar 9, 2016 · 6 comments
Labels

Comments

@lucian303
Copy link
Contributor

Once I set the adapter to Socket, it works, but with Curl or the default adapter (which I assume is Curl), I get this message on chunked encodings. From looking at other tickets and my own experience with prior Zend versions, it looks like the Socket adapter used to be unable to handle the chunked transfer encoding while the Curl one was able to and now that has flipped in ZF 2.5.3. In 2.2.10 for example, I'm 99.9% sure it's the other way.

@marcelto
Copy link
Contributor

marcelto commented Mar 9, 2016

This may not be relevant but in the past I've found that curl sometimes has trouble with chunked responses. To work around the issue I had to set the HTTP version to 1.0.

curl_setopt($ch, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_0);

@lucian303
Copy link
Contributor Author

So I did more investigation and found the culprit in Zend\Http\Client\Adapter\Curl.php:437:

$responseHeaders = preg_replace("/Transfer-Encoding:\s*chunked\\r\\n/", "", $responseHeaders);

Should be:

$responseHeaders = preg_replace("/Transfer-Encoding:\s*chunked\\r\\n/i", "", $responseHeaders);

Notice the 'i' in the regex. It should be a case insensitive match as HTTP headers are case insensitive: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html

@lucian303
Copy link
Contributor Author

See pull request: zendframework/zend-http#53

@sgehrig
Copy link
Contributor

sgehrig commented May 3, 2016

Isn't that a duplicate of zendframework/zend-http#19

Any idea when this would be fixed?

@GeeH
Copy link

GeeH commented Jun 28, 2016

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html
New issue can be found at: zendframework/zend-http#65

@GeeH GeeH closed this as completed Jun 28, 2016
@ezimuel
Copy link
Contributor

ezimuel commented Aug 4, 2016

Fixed in zendframework/zend-http#53.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants