feat: add Content-Encoding option for file operations#1125
feat: add Content-Encoding option for file operations#1125mishushakov wants to merge 9 commits intomainfrom
Conversation
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 detectedLatest commit: 9bdae77 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
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>
There was a problem hiding this comment.
💡 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".
packages/python-sdk/tests/sync/sandbox_sync/files/test_content_encoding.py
Outdated
Show resolved
Hide resolved
read(..., format="bytes") returns bytearray, not bytes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
packages/python-sdk/tests/sync/sandbox_sync/files/test_content_encoding.py
Outdated
Show resolved
Hide resolved
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>
|
@jakubno lmk if we should default all upload/download ops to gzip once the infra's rolled out? |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
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>
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
contentEncodingtoFilesystemRequestOpts, gzip compression in write ops, header passing in read/writecontent_encodingparameter, gzip compression viagzip.compress(), header passingTesting
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
gzipCompresshelper) and setsContent-Encoding: gzip, while reads setAccept-Encoding: gzipto 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.