fix(net): scope passive callbacks to the registering page (#414)

The on_request/on_response Vec lived on the ObscuraHttpClient shared by
every page in the context, so a callback registered on one page fired for
all pages (#408 cross-page bleed) and outlived its page.

Callbacks now live in a per-page CallbackRegistry (Arc shared with the
page's JS runtime state). Page-driven fetch paths (navigation, POST,
scripts, stylesheets, robots.txt, module loads, JS fetch/XHR in both
plain and stealth modes) pass the registry through; the HTTP client
itself is callback-free.

Adds callbacks_do_not_bleed_across_pages: page A's callback stays silent
for page B's requests and stops firing after page A is dropped.
This commit is contained in:
Jim Zhang @ wonderhoi authored and GitHub committed 2026-07-16 12:43:13 +02:00
1 parent ccfa5fb87b
commit f5dc97b131
8 files changed
+249 -108

No files matched your search

+3 -2
View File
@@ -8,8 +8,9 @@ pub mod blocklist;
pub mod wreq_client;
pub use client::{
env_allows_private_network, is_forbidden_ip, ObscuraHttpClient, ObscuraNetError, RequestCallback,
RequestInfo, ResourceType, Response, ResponseCallback, SsrfGuardResolver,
env_allows_private_network, is_forbidden_ip, CallbackRegistry, ObscuraHttpClient,
ObscuraNetError, RequestCallback, RequestInfo, ResourceType, Response, ResponseCallback,
SsrfGuardResolver,
};
pub use cookies::{default_cookie_path, CookieInfo, CookieJar};
pub use encoding::{