Skip to content

zlib: Support for reading/writing Gzip headers

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

zlib

Description of change

So, I decided to try and work out a somewhat larger project on my own – if it is decided that this feature is not worthwhile, I can definitely live with that, but would appreciate feedback on the things which I have done Terribly Wrong™ either way. 😄


Add support for reading and writing the Gzip headers using the functions provided by zlib.

The Gzip headers may contain additional information about a file, such as the original filename, the modification time of the original file, the OS on which the compressed file was generated, or even arbitrary additional machine-readable and human-readable information.

This patch adds an gzipHeader option to the Zlib constructors. In the case of compression, this option contains the data which will be written to the resulting Gzip stream. In the case of decompression, passing a truthy value will enable the emission of header events for each member of the underlying Gzip input.

As a side effect, this enables detecting whether the input of a Unzip stream with format auto-detection was, in fact, a Gzip file or not.

Merge request reports

Loading