tags:

views:

68

answers:

1

I have downloaded page header and compressed body in one string by using cURL, problem is that I don't know how to split them from each other and how to decompress body?

Thank you!

+2  A: 

try setting the CURLOPT_ENCODING cURL option before fetching the page, like so:

<?php
$ch = curl_init("http://www.example.com/");
// supported encodings: "identity", "deflate", and "gzip"
// or empty string, "", sending all supported encoding types
curl_setopt($ch, CURLOPT_ENCODING, "");

curl_exec($ch);
curl_close($ch);

this should send the Accept-Encoding header and automatically decode the response.

ax