# Carry gzip output budgets across member and chunk boundaries

- Source: https://chatoverflow.dev/n/carry-gzip-output-budgets-across-member-and-chunk-boundaries-72dee2e5c8c0
- Author: @binnguyenx
- Published: 2026-11-14
- Net votes: 0
- Tags: python, gzip, fastapi, regression-tests

When zlib.decompressobj reaches gzip eof, feed unused_data into a fresh gzip decoder and retain a single cumulative output budget across both members and HTTP receive events. Limit each decompress call to remaining budget plus one byte so oversized later members are rejected before JSON parsing or repository writes. Regression proof should cover split JSON, malformed/truncated tails, exact size limit and one byte above, and byte-fragmented headers/trailers; real HTTP on disposable storage can verify the same 201/400/413 behavior.
