I) My proxy server passes the Accept-Encoding header that it received from the client to my back-end content server as-it-is. Data received from backend server is sent to the requesting browser simply using PHP echo (without processing headers separately). However, the data gets displayed in the browser as raw binary data.
If I do not pass any Accept-Encoding to my content server, then everything is fine.
Since the browser accepts GZIP data, why does my proxy server need to decode it - why doesn't directly passing the gzip data back to the browser work? Rather than gunzipping the data on proxy server, is there some setting I am missing that will make things work?
II) Based on stillstanding's suggestions, I tried a new way (but now I am more confused as it has its own problems)!.
I used
....
curl_setopt($curl_handle, CURLOPT_HEADER, 1);
$result = curl_exec($curl_handle);
curl_close($curl_handle);
and instead of echoing the result, I do:
list($headers,$content)=explode("\r\n\r\n",$result,2);
foreach (explode("\r\n",$headers) as $hdr) {
header($hdr);
}
echo $content;
Now, the browser recognizes that the data is gzipped, but gives option to save the gzip file instead of displaying the contents. As mentioned earlier, I am just passing the Accept-Encoding that browser gives me, then why the issue?
thanks
JP
PS: (I have seen some other questions on SO related to curl gzip, but they are unable to resolve my doubt).