Tuesday, 29 June 2021

Disable Chrome's gzip automatic decompression

Recently, I have been dealing with a issue on Chrome that made it not possible to save correctly a compressed gzip file.

The root problem is described in this post: Downloaded Gzip seems to be currupted (Chrome)

As described in the link, the file is correctly downloaded in Firefox, because the blob that the AJAX response receives, is gzip encoded, and therefore correctly saved as .gz file. But when the blob data is received in Chrome, it is automatically decompressed, obtaining plain text (UTF-8 encoded) instead of the gzip encoding that we are looking after. This makes the saved file to be corrupted, because it is being saved a UTF-8 encoded blob in a file that is supposed to be gzipped.

After some research, I finally found which was the cause of the problem: Apparently when content-encoding: gzip header is specified in the server response, Chrome automatically decompresses the file, assuming that the main reason of using the gzip compression, is only due to saving bandwidth purposes. This problem is more thoroughly described in the following post: Chromium: prevent unpacking tar.gz

In that post gzip compression is enabled to wrap a .tar file, however in my case, there is not a file beneath the gzip compression ( I directly write data to the gzip file in the server side, using gzip python module). Thus, when Chrome decompress the gzip, there is only plain text. I have tried to explicitly send the response without specifying the content-encoding header, but it seems that Chrome automatically detects the encoding.

Is there anyway that I could disable Chromes's gzip automatic decompression?



from Disable Chrome's gzip automatic decompression

No comments:

Post a Comment