Rewrite Sourcepoint responses without Content-Length - #1183
Draft
ChristianPavilonis wants to merge 2 commits into
Draft
ChristianPavilonis wants to merge 2 commits into
ChristianPavilonis wants to merge 2 commits into
Conversation
Allow bounded JavaScript and HTML rewriting when upstream responses omit Content-Length. Request streaming on supported adapters so the 5 MiB collector can stop before buffering an oversized response. Return 502 on collection overflow, retain declared-oversize pass-through, and request identity encoding for site data without overriding its dynamic cache policy. Cover stream limits, rewriting, pass-through, and headers. Closes #1088
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.
Summary
Content-Length, so embedded URLs and privacy-manager assets still use the first-party proxy./mms/v2/get_site_dataresponses and preserve their upstream and cookie-aware cache policy instead of applying the static JavaScript cache policy.Changes
crates/trusted-server-core/src/integrations/sourcepoint.rsdocs/guide/integrations/sourcepoint.mdScope
Limited to the Sourcepoint integration and its documentation, using existing collection and streaming APIs. Most added code is regression coverage. No adapter implementation or browser JavaScript changes are included.
Fastly enforces the limit while reading the upstream stream. Cloudflare and Spin still buffer upstream bodies before the integration checks them; fixing that adapter-level limitation is deferred. This change does not address campaign or consent-state behavior that can suppress the banner.
Closes
Closes #1088
Test plan
cargo test-fastly && cargo test-axumcargo clippy-fastly && cargo clippy-axumcargo fmt --all -- --checkcd crates/trusted-server-js/lib && npx vitest run(893 passed)cd crates/trusted-server-js/lib && npm run formatcd docs && npm run formatcargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1fastly compute servecargo test-cloudflare && cargo test-spincargo clippy-cloudflare && cargo clippy-cloudflare-wasm && cargo clippy-spin-native && cargo clippy-spin-wasmcargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parity(13 passed)cargo test-fastly integrations::sourcepoint(63 passed under Viceroy)The new missing-length JavaScript and HTML tests failed before the fix and passed afterward. Stream tests cover exactly 5 MiB, overflow, understated lengths, and stopping reads at the limit. Independent review found no introduced correctness issues.
Tests use stub upstream streams. A live Sourcepoint exchange, wire framing, and deployed cache behavior have not been smoke-tested.
Checklist
unwrap()in production codelogmacros, notprintln!, as required by CLAUDE.md