0

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!

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.