2

I am creating two gzip files, one which contains only a single gzip member, where as the second one contains 2 gzip members (two files concatenated into a single gzip file).

When I try to download this through a web server, chrome decompresses the first file fine and shows the contents as is.

But when downloading the second file, chrome seems to decompress only the first member and the second member is left uncompressed.

I tried opening the second file using 7zip and verified that the contents are fine.

Below is the code I am using to generate the two files in C#

FileStream fileStream = new FileStream("D:\\single_big_gzip.gz", FileMode.Create);
FileStream fileStream2 = new FileStream("D:\\multiple_gzip_files.gz", FileMode.Create);

// Write to First file
GZipStream gzipStream = new GZipStream(fileStream, CompressionMode.Compress, false);
StreamWriter writer = new StreamWriter(gzipStream);
writer.WriteLine("hello world!");
writer.Flush();
gzipStream.Close();
fileStream.Close();

// write to second file
gzipStream = new GZipStream(fileStream2, CompressionMode.Compress, true);
writer = new StreamWriter(gzipStream);
writer.WriteLine("Hello world!");
writer.Flush();
gzipStream.Close();

gzipStream = new GZipStream(fileStream2, CompressionMode.Compress, true);
writer = new StreamWriter(gzipStream);
writer.WriteLine("Bye Bye Birdie!");
writer.Flush();
gzipStream.Close();
fileStream2.Close();

Any idea how I can get chrome to decompress the entire second file?

Thank you.

Izaaz Yunus
  • 2,828
  • 1
  • 19
  • 28
  • gzip files is not really meant to contain more than one file, you sure you don't want to produce a zip file instead? – Lasse V. Karlsen Apr 02 '15 at 20:18
  • I have one massive gzip file and one small gzip file. I want to merge them both together before giving it to the user as a single file (concatenated). I dont want to decompress both and add them together to generate a new file. – Izaaz Yunus Apr 02 '15 at 20:25
  • I understand that you did it, but it is usually not done, as such not many programs will figure out that part, they will usually stop after decompressing the first file. Getting chrome to change is going to be hard, it is easier to change your own program, so that is my advice. – Lasse V. Karlsen Apr 02 '15 at 20:28
  • Is there any other compression method that lets you do this or is there any other way to not open up two compressed files and serve them to the user as one file? – Izaaz Yunus Apr 02 '15 at 21:21

1 Answers1

0

Though RFC 1952 specifies that "A gzip file consists of a series of "members" (compressed data sets).", and though gzip properly decodes such streams, browsers generally are not compliant with the standard and will only decode the first member.

Community
  • 1
  • 1
Mark Adler
  • 101,978
  • 13
  • 118
  • 158