3

I have a PHP application that uses Guzzle to make HTTP requests.

I'm getting the following exception:

[curl] 56: Problem (2) in the Chunked-Encoded data [url] http://...

It looks like the problem is with cURL. I've tried to compile latest version of cURL from source, but it looks like it doesn't help.

What could be the problem and how do I fix it?


$ curl --version
curl 7.41.0 (i686-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

$ cat /etc/issue
Ubuntu 14.04.2 LTS \n \l

$ composer show -i

guzzle/guzzle                       v3.9.2             Guzzle is a PHP HTTP client library and framework for building RESTful web service clients
misd/guzzle-bundle                  v1.1.5             Integrates Guzzle into your Symfony2 application

$ apt-cache policy php5-curl

php5-curl:
  Installed: 5.5.9+dfsg-1ubuntu4.6
  Candidate: 5.5.9+dfsg-1ubuntu4.6
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202

4 Answers4

7

Same problem, solved by upgrade to curl to 7.36 (for some reason apt-get install didn't update as of 14 Aug 2015)

$ sudo add-apt-repository ppa:costamagnagianfranco/ettercap-stable-backports
$ sudo apt-get update
$ sudo apt-get install curl
Slava V
  • 16,686
  • 14
  • 60
  • 63
3

Curl 6+ solution

(new Client)->post(http://post.com, [
    'multipart' => $post,
    'curl'        => [
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0,
    ],
]);

Basically force http 1.0 because reasons.

Yauheni Prakopchyk
  • 10,202
  • 4
  • 33
  • 37
2

I had a similir probem and solved it by using http/1.0 it is a very weird thing but it looks like something is wrong in the libcurl or the curl php module and guzzle fails in the post-process of the response.

I wrote a post here describing the thing

Adam
  • 5,091
  • 5
  • 32
  • 49
jhmilan
  • 508
  • 3
  • 12
1

This sounds earliy familiar to the issues mentioned by Michael Dowling (Guzzle creator) on his blog about Chunked Transfer Encoding in PHP with Guzzle.

To answer the question of "how do I fix it" your options could be either:

  1. modify the settings of the web service (may or may not be feasible); and/or
  2. modify your request object.

Without code displaying how your client and request objects or your curl "call" I would simply be speculating.

Shaun Bramley
  • 1,989
  • 11
  • 16