php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24725 cURL CURLOPT_ENCODING does not appear to work
Submitted: 2003-07-20 06:56 UTC Modified: 2003-07-22 10:25 UTC
From: Julian_bond at voidstar dot com Assigned: edink (profile)
Status: Closed Package: cURL related
PHP Version: 4.3.2 OS: Redhat 7.3 and MS Win
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Julian_bond at voidstar dot com
New email:
PHP Version: OS:

 

 [2003-07-20 06:56 UTC] Julian_bond at voidstar dot com
Description:
------------
Redhat/7.3 php/4.3.2 libcurl/7.10.5 OpenSSL/0.9.6b zlib/1.1.4
MS Win php/4.3.2 libcurl/7.10.5 OpenSSL/0.9.7b
MS Win php/4.3.3RC1 libcurl/7.10.5 OpenSSL/0.9.7b

See also:
http://bugs.php.net/bug.php?id=23048
http://bugs.php.net/bug.php?id=21995
http://bugs.php.net/bug.php?id=23702

According to the libcurl docuentation, 
  curl_setopt ($ch, CURLOPT_ENCODING,"");
should generate a header 
  HTTP_ACCEPT_ENCODING: gzip,deflate 
And then autodecode the returned data if the remote server supports compression. However in the above three PHP releases it never does. Reading the three bug reports above, it appears that support for this option call may have been added to php 4.3.2 and so the problem is currently viewed as a documentation problem. However after repeated tests, it still appears to be missing from either php and/or libcurl and hence this bug report. The libcurl crew deny responsibility(!) and point at the php implementation. Using curl from the command line with the --compressed option I can see the header and auto-decoding working but I don't have the facilities to check the libcurl library except from inside php.

The libcurl readme
http://cvs.php.net/co.php/curl/lib/README.encoding?r=1.3
says that "The library zlib is required for this feature." but as can be seen above from the version report, php_curl.dll for windows does not appear to bind the zlib library, so even if the parameter option is being passed to libcurl, it probably wouldn't work anyway.

Reproduce code:
---------------
  $ch = curl_init("http://www.voidstar.com/temp/accept.php");
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_ENCODING,"");
  curl_setopt ($ch, CURLOPT_HEADER, 1);

  $data = curl_exec($ch);

  curl_close ($ch);

  print "<pre>" . htmlentities($data) . "</pre>";


Expected result:
----------------
http://www.voidstar.com/temp/accept.php prints the headers it receives. It's running on a server with zlib support compiled into php and zlib.output_compression = on This can be seen by using a browser that supports gzip to navigate to the url above. In this case the header can be seen.

The reproduce code above should generate the accept_encoding header which should then result in it being mirrored back to curl which then displays it.

 HTTP_ACCEPT_ENCODING: gzip,deflate

Actual result:
--------------
Missing header
 HTTP_ACCEPT_ENCODING: gzip,deflate

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-20 08:26 UTC] julian_bond at voidstar dot com
Installed MS Win release. phpinfo() reports
php/4.3.3RC2-dev, libcurl/7.10.5 OpenSSL/0.9.7b
No change. Curl is still not generating the header. php-curl still does not appear to support zlib.

Currently creating a test environment where I can test php under Redhat as I found the problem on a production server. Might take a little while. Will report back.
 [2003-07-20 08:38 UTC] sniper@php.net
DO NOT use 'Add Comment' when you edit your own report!!!
(use this url: http://bugs.php.net/bug.php?id=24725&edit=2)

 [2003-07-20 08:42 UTC] sniper@php.net
Just a build issue with curl libs. (Edin, can you add zlib in the curl stuff?)

 [2003-07-20 10:22 UTC] sniper@php.net
There was a small bug in the php curl, but it's fixed now.
Now the encoding works as long as libcurl is linked with zlib. (Edin, is the libcurl used by win32 stuff linked with it??)

 [2003-07-20 10:54 UTC] Julian_bond at voidstar dot com
Got there eventually. I can confirm that the snapshot still has the same problem on *nix
redhat/7.3 php/4.3.3RC2-dev 
libcurl/7.10.5 OpenSSL/0.9.6b zlib/1.1.4
php4-STABLE-200307201330

From the comments below, it sounds like the bug has been found. Happy to test it once it's in the snapshot.
 [2003-07-22 05:45 UTC] Julian_bond at voidstar dot com
php4-STABLE-200307220930

To confirm. The bug fix worked and HTTP_ACCEPT_ENCODING is now generated. On Unix with zlib bound into curl, it's correctly requesting gzip, deflate and decoding the result.

On Windows with php_curl, it's generating "identity" as the only supported compression. Almost certainly because php_curl.dll doesn't yet bind zlib.

Thanks guys. Almost there.
 [2003-07-22 07:29 UTC] edink@php.net
Could you please try:

ftp://ftp.proventum.net/misc/php_curl.dll

instead of the originial extension/php_curl.dll?
 [2003-07-22 09:08 UTC] Julian_bond at voidstar dot com
Success! It now works in MS win as well. And phpinfo() reports
libcurl/7.10.5 OpenSSL/0.9.7b zlib/1.1.4

Many thanks.
 [2003-07-22 10:25 UTC] sniper@php.net
Fixed -> closed.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 19:01:32 2024 UTC