All:

I have a small app that uses the cURL functionality in PHP. According to the folks at PHP.NET, I can use CURLOPT_ENCODING() to request compressed content, but of course there is no documentation on it.

System:

  • Redhat 8
  • Apache 2.0.45
  • PHP 4.3.2RC3
  • cURL 7.10.5
  • ZLIB 1.14

Anyone out there know how to get the following code to send the "Accept-encoding: gzip" client request header? This is how libcURL states it should work.


$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $target);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, $wget_ua);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);

//
// Convert HTML to escaped characters
//

$test = htmlspecialchars(curl_exec($ch));


Thanks,
Stephen

    Write a Reply...