wire / wire-format / zlib-format
zlib wraps a DEFLATE stream with a 2-byte header (CMF + FLG) and a 4-byte Adler-32 trailer. The header encodes the compression method (always 8 = DEFLATE), window size, and flags. The FLG byte's high 4 bits must make (CMF*256 + FLG) a multiple of 31.
aka: zlib compressed data format (RFC 1950)
spec: RFC 1950
zlib wraps a DEFLATE stream with a 2-byte header (CMF + FLG) and a 4-byte Adler-32 trailer. The header encodes the compression method (always 8 = DEFLATE), window size, and flags. The FLG byte's high 4 bits must make (CMF*256 + FLG) a multiple of 31.
| field | size | meaning |
|---|---|---|
| CMF | 1 byte | Compression Method and Flags: low 4 bits = CM (8 = DEFLATE), high 4 bits = CINFO (log2(window size) - 8, so 7 = 32KB window). |
| FLG | 1 byte | Flags: bits 0-4 = FCHECK (makes CMF*256+FLG divisible by 31), bit 5 = FDICT (preset dictionary), bits 6-7 = FLEVEL (compression level). |
| Dictionary ID | 4 bytes | Present only if FDICT is set; Adler-32 of the preset dictionary. |
| Compressed data | variable | DEFLATE bitstream. |
| Adler-32 | 4 bytes | Adler-32 checksum of the uncompressed data (big-endian). |
example:
78 9c 03 00 00 00 00 01
zlib header (CMF=0x78 DEFLATE/32KB, FLG=0x9C) + empty stored block + Adler-32 of empty (0x00000001)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/zlib-format
or /wire-format/zlib-format.json