4 ms·
Not true. If you specify the Content-Encoding headers, Chrome and Firefox decode and display the images properly.
by rejment 14y ago
Not true. If you specify the Content-Encoding headers, Chrome and Firefox decode and display the images properly.
- samuellb 14y agoDoesn't this mean that IE is doing content-type sniffing?
- rejment 14y agoYes it does. It always has done.
- davecardwell 14y agoYes. You can explicitly turn off this behaviour by sending a “X-Content-Type-Options: nosniff” header for IE8+. http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Common_non-standard_response_headers http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Comm...
- thomseddon 14y agohttp://www.thestudentcloud.co.uk/hn/test.php http://www.thestudentcloud.co.uk/hn/test.php doesn't work for me in Chrome 21, but does in Opera 11? Source: <?php header('Content-Encoding: gzip'); header('Content-Type: image/jpeg'); $fin = fopen('test.jpg', "rb"); $fout = fopen('php://output', "w"); $gzipFilter = stream_filter_append($fout, 'zlib.deflate', STREAM_FILTER_WRITE, array('level' => 6, 'window' => 15, 'memory' => 9)); stream_copy_to_stream($fin, $fout); stream_filter_remove($gzipFilter); fclose($fin); fclose($fout);
- pilif 14y agoContent-Encoding: gzip implies a gz header. zlib.deflate just deflates and emits headerless data. Because creating a valid header requires the length of the content to be known, there's no stream filter in PHP to create a gz header. To see Chrome decode your test image, use gzencode() or set Content-Encoding to deflate.
- thomseddon 14y agoRight you are! Thanks alot. http://www.thestudentcloud.co.uk/hn/test2.php http://www.thestudentcloud.co.uk/hn/test2.php <?php header('Content-Encoding: gzip'); header('Content-Type: image/jpeg'); $data = file_get_contents('test.jpg'); $gzdata = gzencode($data, 9); $fout = fopen('php://output', "w"); fwrite($fout, $gzdata); fclose($fout);