blackbull.grpc.compression¶
blackbull.grpc.compression
¶
Per-message gRPC gzip compression.
The flag and length stay uncompressed, so this is not whole-body middleware. Callers translate DecompressionError into status; this codec owns no status.
DecompressionBombError
¶
Bases: DecompressionError
Decompressed output exceeded the caller's size limit — a small compressed frame that inflates past the per-message cap (a "zip bomb").
DecompressionError
¶
Bases: ValueError
A compressed request message could not be decompressed (corrupt stream, or an output larger than the caller's limit).
compress_gzip(data)
¶
Compress data into a single gzip stream.
decompress_gzip(data, max_output)
¶
Decompress one gzip member, refusing to produce more than max_output.
The 4-byte LPM prefix bounds the compressed size only, so the cap uses
decompress(..., max_output + 1) and unconsumed_tail and raises
DecompressionBombError.
A message is exactly one complete member, so input that ends before the
member does (its CRC was never verified; mid-deflate the output is silently
partial), a stream zlib rejects and any trailing byte — a second member
included — raise DecompressionError. That includes an empty body.
supports(encoding)
¶
Return True if encoding is one this module can (de)compress.