Repository navigation
fix(gateway): expose Content-Encoding to cross-origin readers - #2870
Merged
Merged
Conversation
A proxy in front of a public gateway can encode the body, and then Content-Length counts the encoded bytes. Content-Encoding is not CORS-safelisted, so a page on another origin could not tell. The public CORS headers now expose it, and both SDK pins move to the commits that mirror the list in their fake gateways and assert it in the contract suite. Closes #2817 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 11, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A remaining readability nit was flagged in adr/appendix-gateway.md at line 220 for an overly long unwrapped line that should be wrapped to match the document’s formatting conventions.
1 open issue
What changed in this PR
Updates the public gateway’s CORS exposed-headers configuration so cross-origin clients can read Content-Encoding, enabling SDKs to correctly interpret Content-Length when responses are compressed by an upstream proxy/CDN.
Changes:
- Expose
Content-EncodingviaAccess-Control-Expose-Headersfor public gateway responses. - Update public CORS contract tests to expect
Content-Encodingas readable cross-origin. - Document the rationale in the gateway appendix and bump pinned TypeScript/Python SDK contract SHAs.
| File | Description |
|---|---|
| crates/cli/src/commands/gateway/tests.rs | Updates the canonical readable-header set used by public CORS tests to include Content-Encoding. |
| crates/cli/src/commands/gateway.rs | Adds Content-Encoding to the public exposed-header list used to build Access-Control-Expose-Headers for public gateway responses. |
| adr/appendix-gateway.md | Documents that Content-Encoding is exposed for cross-origin reads and explains why it’s needed to interpret Content-Length under compression. |
| .github/sdk-typescript.sha | Bumps the pinned sdk-typescript commit to the revision that aligns its gateway contract expectations with exposing content-encoding. |
| .github/sdk-python.sha | Bumps the pinned sdk-python commit to the revision that aligns its gateway contract expectations with exposing content-encoding. |
Review effort: Balanced
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 1 most impacted file.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
Co-Authored-By: Claude Fable 5.2 <[email protected]>
alpergundogdu
added a commit
to decdn/sdk-typescript
that referenced
this pull request
Nov 11, 2026
The public gateway adds `Content-Encoding` to `Access-Control-Expose-Headers` (decdn/decdn#2817, gateway change in decdn/decdn#2870). A page on another origin then sees that a proxy in front encoded the body, so the client skips `Content-Length` as a lower bound and as `contentLength` (the logic from #21). ## Changes - `test/fake-gateway.ts`: `EXPOSED` lists `Content-Encoding` after `Content-Length`, as the gateway does. - `test/contract/public.test.ts`: a blob read from another origin finds `content-encoding` and `content-length` in `access-control-expose-headers`. - `test/contract/fixture.ts`: `shippedAfter(version)` says whether the gateway under test carries behaviour decdn shipped after that release. `scripts/decdn-contract.sh --tag` sets `DECDN_CONTRACT_RELEASE`; the fake and `--ref` runs (including decdn's own contract run) carry everything. - The new test is declared inside `if (shippedAfter("0.3.1"))`. It is left out, not skipped, because decdn's harness fails a run where any collected test is skipped. CONTRIBUTING.md describes the pattern. ## Order This PR merges first. decdn/decdn#2870 pins `.github/sdk-typescript.sha` to this branch's head. ## Gateway floor `decdn.gatewayFloor` stays at `0.3.0`. The SDK code does not change, and the release-gateway runs against v0.3.0 and v0.3.1 do not collect the new test. ## Tests - `pnpm lint`, `pnpm build`, `shellcheck scripts/decdn-contract.sh`: pass. - `vitest run test/contract test/unit`: 155 passed. - Public contract against the fake with `DECDN_CONTRACT_RELEASE` set to 0.3.0 or 0.3.1: 16 tests, none skipped. Set to 0.3.2: 17. - `test/scripts/*` fail locally on macOS (BSD `tar --mtime`, changelog tool), unrelated to this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
alpergundogdu
added a commit
to decdn/sdk-python
that referenced
this pull request
Nov 11, 2026
The public gateway adds `Content-Encoding` to `Access-Control-Expose-Headers` (decdn/decdn#2817, gateway change in decdn/decdn#2870), so a page on another origin can tell that a proxy in front encoded the body. ## Changes - `tests/fake_gateway.py` and `tests/unit/test_fake_gateway.py`: `EXPOSED` lists `Content-Encoding` after `Content-Length`, as the gateway does. - `tests/contract/test_public.py`: a blob read with an `Origin` finds `content-encoding` and `content-length` in `access-control-expose-headers`. - `tests/contract/fixture.py`: `shipped_after(version)` says whether the gateway under test carries behaviour decdn shipped after that release. `scripts/decdn-contract.sh --tag` sets `DECDN_CONTRACT_RELEASE`; the fake and `--ref` runs carry everything. - The new test is declared inside `if shipped_after("0.3.1"):`. It is left out, not skipped, because decdn's harness fails a run where any collected test is skipped. CONTRIBUTING.md describes the pattern. This is the same gate as decdn/sdk-typescript#25. ## Order This PR merges first. decdn/decdn#2870 pins `.github/sdk-python.sha` to this branch's head. ## Gateway floor `gateway-floor` stays as is: the SDK code does not change, and the weekly release-gateway runs do not collect the new test. ## Tests - `uv run ruff check .`, `uv run ruff format --check .`, `uv run mypy`, `shellcheck scripts/decdn-contract.sh`: pass. - `uv run pytest tests/unit tests/contract`: 354 passed. - With `DECDN_CONTRACT_RELEASE=0.3.1` the new test is not collected; with 0.3.2 or 0.4.0-rc.1 it runs and passes. - `tests/scripts/test_decdn_contract.py` fails locally on macOS, unrelated to this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Closes #2817
A compressing proxy in front of a public gateway sets
Content-Encoding, andContent-Lengththen counts the encoded bytes.Content-Encodingis not CORS-safelisted, so a page on another origin could not see it, and@decdn/clienttreatedContent-Lengthas a lower bound on a decoded body.Changes
crates/cli/src/commands/gateway.rs:PUBLIC_EXPOSEDlistsContent-EncodingafterContent-Length.crates/cli/src/commands/gateway/tests.rs:READABLE, which every public CORS test compares against, lists it too.adr/appendix-gateway.md§ Cross-origin reads names the header and why a page needs it..github/sdk-typescript.sha→970bcff2(test(contract): expect Content-Encoding among the exposed headers sdk-typescript#25)..github/sdk-python.sha→7e7d7804(test(contract): expect Content-Encoding among the exposed headers sdk-python#12).SDK PRs merge first
Each adds
Content-Encodingto its fake gateway'sEXPOSEDlist and a public contract test thataccess-control-expose-headersincludescontent-encoding. The test is declared only for gateways that carry this change (shippedAfter("0.3.1")/shipped_after("0.3.1"), driven byDECDN_CONTRACT_RELEASEfromdecdn-contract.sh --tag), so the SDKs' release-gateway runs against v0.3.0 and v0.3.1 keep passing. The gateway floors stay as they are.Merge both SDK PRs before this one. If either head changes, move its pin here. Both SDK repos squash-merge, so after they merge, move both pins to the squash commits on each SDK
mainand let theSDK contractjobs rerun before merging this PR.Tests
cargo fmt -- --check: pass.cargo clippy --workspace --all-targets --all-features -- -D warnings: pass.cargo nextest run -p decdn-cli: 1253 passed.🤖 Generated with Claude Code