Skip to content

feat(requester-node-http): add gzip compression for requests and response decompression#1603

Open
Fluf22 wants to merge 6 commits intov4from
feat/gzip-compression-support
Open

feat(requester-node-http): add gzip compression for requests and response decompression#1603
Fluf22 wants to merge 6 commits intov4from
feat/gzip-compression-support

Conversation

@Fluf22
Copy link
Contributor

@Fluf22 Fluf22 commented Feb 6, 2026

When the accept-encoding header includes gzip, request bodies are compressed with zlib.gzipSync() and a content-encoding: gzip header is added. Responses with content-encoding: gzip are decompressed via zlib.createGunzip(). Decompression errors resolve gracefully following the existing error handling pattern (never reject).

Includes 8 comprehensive tests covering compression, decompression, error handling, multi-value headers, and full round-trip scenarios.

…onse decompression

When the accept-encoding header includes gzip, request bodies are
compressed with zlib.gzipSync() and a content-encoding: gzip header is
added. Responses with content-encoding: gzip are decompressed via
zlib.createGunzip(). Decompression errors resolve gracefully following
the existing error handling pattern (never reject).

Includes 8 comprehensive tests covering compression, decompression,
error handling, multi-value headers, and full round-trip scenarios.
@Fluf22 Fluf22 self-assigned this Feb 6, 2026
@Fluf22 Fluf22 requested a review from shortcuts February 6, 2026 15:47
Use Buffer.byteLength() to set content-length for both compressed and
uncompressed request bodies, avoiding unnecessary chunked transfer
encoding overhead.
Small request bodies gain little from compression and the gzip overhead
can exceed the savings. Only compress when body size >= 1024 bytes.
Release the native zlib handle promptly instead of waiting for garbage
collection. Covers both the error path (decompression failure, response
stream error) and the timeout path (req.abort mid-transfer).
@Fluf22 Fluf22 requested a review from Ant-hem February 9, 2026 16:59
Avoid blocking the event loop during compression. Large payloads
(multiple MB) on server-side would stall all concurrent requests with
the sync API. The async callback compresses on the libuv thread pool.
@Fluf22
Copy link
Contributor Author

Fluf22 commented Feb 12, 2026

@Ant-hem @samouss any last comments?
@shortcuts care for a review please? This got pretty big pretty quick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants