Using encoded transfer and gzip

I recently started using gzip on my site, and it worked like a charm in all browsers except Opera, which gives an error saying that it cannot unzip the contents due to corrupted data. From what I can compile from testing and searching on the Internet, there may be a problem with the use of gzip coding and chunked transfer. The fact that the error when requesting small files, such as css files, is also indicated in this direction.

Is this a known issue or is there something else I was thinking about?

Someone also mentioned that it might have something to do with sending the Content-Length header.

Here is a simplified version of the most important part of my code:

$contents = ob_get_contents();
ob_end_clean();
header('Content-Encoding: '.$encoding);
print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
$size = strlen($contents);
$contents = gzcompress($contents, 9);
$contents = substr($contents, 0, $size);
print($contents);
exit();
+3
2

GZip , , .

Content-Length, .

, gzip, Vary: Accept-Encoding ( ), ETags, .

URL- http://redbot.org/ - gzip.

+7

, , . , , : "Accept-Encoding: gzip, deflate". , , HTTP 1.1.

+2

Source: https://habr.com/ru/post/1741629/


All Articles