I need to get the raw server response, with headers. This also means that gzipped or deflated content should still be compressed. I don’t want any changes done to what is received.
Is this possible with PHP?
I tried with curl but that doesn’t seem to be working, I set these to zero:
CURLOPT_HTTP_CONTENT_DECODING => 0,
CURLOPT_HTTP_TRANSFER_DECODING => 0,
But no help.
I tried with fsockopen but that seems to uncompress automatically as well.
Anything else?
Edit: these are all my curl headers:
$options = array(CURLOPT_URL => 'http://www.example.com/',
CURLOPT_CONNECTTIMEOUT => 20,
CURLOPT_HEADER => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_USERAGENT => $user_agent,
//CURLOPT_CUSTOMREQUEST => 'HEAD',
//CURLOPT_NOBODY => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
//CURLOPT_HTTP_CONTENT_DECODING => 0,
//CURLOPT_HTTP_TRANSFER_DECODING => 0,
CURLOPT_BINARYTRANSFER => 1,
CURLOPT_HTTPHEADER => array('Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language' => 'en-us',
'Accept-Encoding' => 'gzip, deflate'));
Thanks.
fsockopen won’t automatically decompress, but you if you are rolling your own HTTP client, you must tell the server you’re ready to accept a gzipped response, other the server will send you an uncompressed one.
You can do this by including an Accept-Encoding header in your request, e.g.