Skip to content

[CHA-2964] gzip request and response#259

Merged
mogita merged 2 commits into
mainfrom
feat/cha-2964-gzip-request-and-response
May 26, 2026
Merged

[CHA-2964] gzip request and response#259
mogita merged 2 commits into
mainfrom
feat/cha-2964-gzip-request-and-response

Conversation

@mogita
Copy link
Copy Markdown
Contributor

@mogita mogita commented May 26, 2026

Summary

  • Adds Accept-Encoding: gzip to the SDK's default httpx.Client and httpx.AsyncClient (sync + async parity).
  • httpx auto-decodes Content-Encoding: gzip responses — no additional decode code needed.
  • Escape hatch (user-supplied http_client) is untouched.

Spec

Test plan

  • New tests/test_gzip.py: 5 tests covering sync + async request header + sync + async response decode + escape-hatch regression guard. All pass locally.
  • Smoke: full unit-only suite passes locally (264 passed / 5 skipped).
  • CI green

Summary by CodeRabbit

Release Notes

  • New Features
    • The SDK now automatically supports gzip compression for HTTP requests to improve performance when the server supports it.
    • Compressed responses are transparently decompressed automatically.
    • Custom HTTP client configurations provided by users are properly respected.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2c65ea98-7d7f-4aeb-aade-226f4fe2f9e7

📥 Commits

Reviewing files that changed from the base of the PR and between 765076f and 64e97b7.

📒 Files selected for processing (2)
  • getstream/base.py
  • tests/test_gzip.py

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

The PR adds automatic gzip support to the Stream SDK's HTTP clients. BaseClient and AsyncBaseClient now merge Accept-Encoding: gzip into their default headers when creating internal httpx clients. New test coverage verifies header injection, response decompression for both sync and async paths, and that user-provided clients retain their explicit encoding headers.

Changes

Gzip content encoding support

Layer / File(s) Summary
Accept-Encoding header injection
getstream/base.py
BaseClient and AsyncBaseClient.__init__ merge Accept-Encoding: gzip into the headers dict passed to the internal httpx.Client and httpx.AsyncClient, covering both transport-backed and non-transport-backed construction branches.
Gzip handling test suite
tests/test_gzip.py
Helper functions (_capture_transport, _gzip_response_transport) mock transports. Tests verify default sync/async clients send Accept-Encoding: gzip, decode gzip-compressed responses transparently, and a regression guard ensures user-provided clients with explicit Accept-Encoding: identity are not overwritten.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 Gzip springs forth with headers set,
Responses shrink, no test is fret,
User choice is still their own,
The escape hatch, safe and known. 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cha-2964-gzip-request-and-response

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mogita mogita marked this pull request as ready for review May 26, 2026 15:52
@mogita mogita merged commit 91fdc5a into main May 26, 2026
45 of 49 checks passed
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.

1 participant