Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

Projects
None yet
6 participants
@lucian303
Copy link
Contributor

commented Mar 9, 2016

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Mar 9, 2016

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

This comment has been minimized.

Copy link
Contributor Author

commented Mar 9, 2016

See pull request: zendframework/zend-http#53

@adamlundrigan adamlundrigan added the Http label Mar 10, 2016

@sgehrig

This comment has been minimized.

Copy link
Contributor

commented May 3, 2016

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

Any idea when this would be fixed?

@GeeH

This comment has been minimized.

Copy link

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 Jun 28, 2016

@ezimuel

This comment has been minimized.

Copy link
Member

commented Aug 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.