Expand description
Request interception logic for blocking unwanted network requests.
When a browser page has resource blocking or domain blocking enabled, every outgoing request is evaluated by the functions in this module before it is allowed to proceed. There are two independent blocking mechanisms:
-
Resource-type blocking (
should_block_resource) – drops requests for heavyweight resource types like images, fonts, stylesheets, and media whendisable_resourcesistrue. The exact list of blocked types is defined in [constants::EXTRA_RESOURCES]. -
Domain blocking (
is_domain_blocked) – drops requests whose hostname (or any parent domain suffix) appears in a blocklist. This powers both custom domain blocking and the built-in ad/tracker blocklist.
The top-level should_block_request function combines both checks and is the
one wired into Playwright’s route handler in crate::fetcher.
Functions§
- is_
domain_ blocked - Returns
trueifhostname(or any of its parent domains) appears inblocked_domains. - should_
block_ request - Returns
trueif a request should be blocked based on its resource type or domain. - should_
block_ resource - Returns
trueif the given resource type should be blocked when resource blocking is enabled.