cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Unzipping gzip compressed response

From: Graham Charters <gcharters_at_googlemail.com>
Date: Thu, 1 Feb 2007 09:28:24 +0000

Hi,

I'm using the PHP curl extension to prototype RSS client support in a
project I work on. I recently encountered an example of a feed which was
coming back gzip compressed.

My request headers include the following:

Accept-Encoding: gzip

And the response headers include:

Content-Encoding: gzip

The relevant (I think :-) ) parts of my request code are:

curl_setopt($handle, CURLOPT_HEADER, false);
curl_setopt($handle, CURLOPT_ENCODING, "gzip");
$result = curl_exec($handle);

I was under the impression that curl would automatically unzip a gziped
response for me, but $result is still compressed. I can unzip the respone
myself using the following:

$unzipped = gzinflate(substr($result,10));

I'm not comfortable doing this if the response should actually already be
unzipped as my code will probably break when the behaviour changes.

Could someone please tell me whether or not curl should be unzipping the
response, or whether there is something I need to do to enable this?

FYI: I've tried this with curl 7.15.5 and 7.16.1 (built with Open SSL
0.9.8band d) and the result is the same for both.

Any help would be greatly appreciated. Many thanks.

Regards,

Graham.

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-02-01