feat(requester-node-http): add gzip compression for requests and response decompression#1603
Open
feat(requester-node-http): add gzip compression for requests and response decompression#1603
Conversation
…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.
Ant-hem
reviewed
Feb 6, 2026
Ant-hem
reviewed
Feb 9, 2026
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).
samouss
reviewed
Feb 9, 2026
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.
Contributor
Author
|
@Ant-hem @samouss any last comments? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.