Raw Deflate: Skipping the Zlib Header

When decompressing data that was compressed by tools like Erlang’s zlib:zip, the stream often lacks a standard header. Standard inflate calls expect that header and will fail on such input.

The fix is a negative windowBits value in zlib, usually in the range -8 to -15. As documented in zlib.h, a negative value tells inflate() to process raw deflate data: it skips any header check, generates no check value, and performs no trailing checksum verification.

In Ruby, this translates to passing -15 when creating the inflater:

zs = Zlib::Inflate.new(-15)
unzipped = zs.inflate(string)
zs.finish
zs.close

This approach is useful when you know the payload is pure deflate without zlib or gzip framing — but remember you lose the integrity checks those headers normally provide.