Skip to content

feat: add Content-Encoding option for file operations#1125

Open
mishushakov wants to merge 9 commits intomainfrom
mishushakov/content-encoding
Open

feat: add Content-Encoding option for file operations#1125
mishushakov wants to merge 9 commits intomainfrom
mishushakov/content-encoding

Conversation

@mishushakov
Copy link
Member

@mishushakov mishushakov commented Feb 10, 2026

Waiting on e2b-dev/infra#1811

Summary

Add optional contentEncoding: 'gzip' parameter to sandbox file read/write operations across JS and Python SDKs. When enabled, uploads are gzip-compressed and downloads request compressed responses. Both HTTP clients (fetch/httpx) automatically decompress responses, so no manual decompression is needed.

Changes

  • JS SDK: Added contentEncoding to FilesystemRequestOpts, gzip compression in write ops, header passing in read/write
  • Python SDK (sync/async): Added content_encoding parameter, gzip compression via gzip.compress(), header passing

Testing

Format and lint pass. JS build succeeds. Ready for integration testing with envd backend.


Note

Medium Risk
Touches core file transfer paths and HTTP headers/body encoding; failures could break uploads/downloads or cause backend incompatibilities, though behavior is opt-in and covered by new integration-style tests.

Overview
Adds an optional encoding: 'gzip' option to sandbox filesystem read/write APIs in both JS and Python SDKs.

When enabled, JS writes gzip-compressed multipart uploads (via new gzipCompress helper) and sets Content-Encoding: gzip, while reads set Accept-Encoding: gzip to request compressed responses. Python sync/async clients mirror this by gzip-compressing uploaded file parts and sending the same headers, with new tests covering gzip reads/writes (including multi-file uploads and byte reads) and a changeset bumping both packages.

Written by Cursor Bugbot for commit 9bdae77. This will update automatically on new commits. Configure here.

Add optional `contentEncoding` parameter to file read/write methods in both JS and Python SDKs. When set to 'gzip', the SDK will set the Content-Encoding header on requests. Downloads automatically decompress via native HTTP client support (fetch/httpx).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: 9bdae77

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/python-sdk Patch
e2b Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

mishushakov and others added 3 commits February 10, 2026 17:24
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TextIOBase is a subclass of IOBase, so a single IOBase check with
an isinstance(raw, str) guard handles both cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mishushakov mishushakov marked this pull request as ready for review February 10, 2026 16:45
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b15a8f7115

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

read(..., format="bytes") returns bytearray, not bytes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Content-Encoding describes the encoding of the request body, which is
absent in GET requests. Accept-Encoding is the correct header to signal
that the client wants a compressed response.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mishushakov
Copy link
Member Author

@jakubno lmk if we should default all upload/download ops to gzip once the infra's rolled out?

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Encode str to bytes unconditionally before passing to gzip.compress,
and restore TextIOBase handling for IO streams.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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

Comments