6

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?

3

1 Answer 1

0

Answer. set a new custom header accept-encoding to either: an empty value or. gzip;q=0,deflate;q=0 either should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.