S023: request headers (DNT, Sec-GPC, Save-Data) and third-party cookie blocking in the vendored servo-net

New vendor/servo-net/nacre.rs holds embedder-set state; http_loader and
websocket_loader read it. Settings rows are working switches; privacy mode
turns blocking on. Loopback smoke tests/smoke/privacy-net.txt, unit tests
for site matching. Patch list in DESIGN.md, D-017.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-12 15:34:32 -06:00
commit f5cb6f76f8

View file

@ -145,6 +145,30 @@ picture-in-picture, extensions, password capture, printing.
(`inject.rs`) copies each icon's computed colour into its `color` attribute (hover colours not followed).
- CSS `mask-image` icons (e.g. Wikipedia's) paint as solid squares. HTTP/2 header limit: see D-012.
## Vendored servo-net patches
`vendor/servo-net` is servo-net 0.7.0 through `[patch.crates-io]` (D-012). Every Nacre change is marked
`Nacre patch` in the code; a Servo upgrade re-applies the ones upstream still needs, then re-runs the smoke scripts named.
| File, function | What and why | Re-check |
|---|---|---|
| `connector.rs` `create_http_client` | `http2_max_header_list_size(256 KiB)`: hyper's 16 KiB default refuses YouTube's response headers (D-012) | `heavy-web.txt` |
| `fetch/methods.rs` `main_fetch` (scheme fetch) | lets the certificate warning's `chrome:allowcert` request through; it ended as UnsupportedScheme (D-014) | `net-privacy.txt` |
| `http_cache.rs` `flush_to_disk`, `resource_thread.rs` Exit | writes the memory HTTP cache to the disk cache at quit (D-014) | `cache.txt`, `cache-restart.txt` |
| `nacre.rs` (new module, `pub mod nacre` in `lib.rs`) | embedder-set state the patches below read: extra request headers, the third-party cookie switch, the top-level site per webview, site matching (S023) | `privacy-net.txt` |
| `http_loader.rs` `http_network_or_cache_fetch` (step 8.15) | appends the embedder's extra headers (`DNT`, `Sec-GPC`, `Save-Data`) unless the request already has them; records a `Document` request's site as its webview's top-level site; skips the `Cookie` header for a third-party request (S023) | `privacy-net.txt` |
| `http_loader.rs` `http_network_fetch` (step 15) | doesn't store `Set-Cookie` from a third-party response (S023) | `privacy-net.txt` |
| `websocket_loader.rs` `create_handshake_request`, `process_ws_response` | the same third-party rule for WebSocket handshakes (S023) | unit tests only |
Third-party rule (S023): a request is third-party when its host's site (registrable domain, eTLD+1; an IP address
or a single-label host stands for itself) differs from the top-level site of its webview. Scheme and port don't
count, so `a.example.com` on `example.com` stays first-party. The top-level site comes from the last `Document`
request of that webview (net sees it before any subresource) and from the hub's `notify_url_changed` (history
navigations without a request, downloads that didn't replace the page); `notify_closed` forgets it. Requests with no
webview or no known top-level site are never blocked. `Document` requests are never blocked; `IFrame` documents are
checked like any subresource. Not covered: `document.cookie` and the Cookie Store API in a third-party frame
(script sends those to net with no webview id; servo-script isn't vendored).
## UI system (S015)
Everything the interface draws takes its colours, radii, sizes and springs from `src/theme.rs`; widgets live in