Literal bytes and backward references
The stream emits literal bytes or a length and backward distance instructing the decoder to copy previous output. RFC1951 permits lengths3–258 and distances1–32768; compressors may search a smaller range.
Copies may overlap current output: after XY, length5 at distance2 appends XYXYX. References can cross block boundaries, so a new block does not automatically reset history or provide an independent decoding point.
References: [1]
Block headers determine decoding
A header marks the final block and selects stored, fixed-Huffman or dynamic-Huffman encoding. Dynamic blocks transmit code-length information; fixed blocks use predefined codes without sending a new tree.
Lengths may include extra bits. Huffman-coded blocks use symbol256 to mark their end; stored blocks instead end after LEN bytes, with NLEN checking that length. Compressor choices about matching and boundaries affect speed and size, but a conforming decoder need not reproduce that search strategy. A format is not one optimal compression algorithm.
References: [1]
Streams, wrappers and resource limits
gzip and zlib can wrap DEFLATE but have different headers, trailers and checks. Raw DEFLATE or zlib output is not automatically accepted by a gzip-only interface; APIs must specify the representation layer.
A bounded history distance does not bound total decompressed output or supply random access. Output and resource limits remain separate controls, and complete size includes block headers, code descriptions and wrapper information.