pub struct NetworkManager {
pub request_timeout: Duration,
pub ignore_visuals: bool,
pub block_stylesheets: bool,
pub block_javascript: bool,
pub block_analytics: bool,
pub only_html: bool,
pub xml_document: bool,
pub intercept_manager: NetworkInterceptManager,
pub document_reload_tracker: u8,
pub document_target_url: String,
pub document_target_domain: String,
pub max_bytes_allowed: Option<u64>,
/* private fields */
}Expand description
The base network manager.
Fields§
§request_timeout: DurationThe page request timeout.
ignore_visuals: boolIgnore visuals (no pings, prefetching, and etc).
block_stylesheets: boolBlock CSS stylesheets.
block_javascript: boolBlock javascript that is not critical to rendering.
NOTE: With “allow all scripts unless blocklisted”, this no longer blocks scripts by itself (it remains for config compatibility).
block_analytics: boolBlock analytics from rendering
only_html: boolOnly html from loading.
xml_document: boolIs xml document?
intercept_manager: NetworkInterceptManagerThe custom intercept handle logic to run on the website.
document_reload_tracker: u8Track the amount of times the document reloaded.
document_target_url: StringThe initial target url. We want to use a new page on every navigation to prevent re-using the old domain.
document_target_domain: StringThe initial target domain. We want to use a new page on every navigation to prevent re-using the old domain.
max_bytes_allowed: Option<u64>The max bytes to receive.
Implementations§
Source§impl NetworkManager
impl NetworkManager
Sourcepub fn set_whitelist_patterns<I, S>(&mut self, patterns: I)
pub fn set_whitelist_patterns<I, S>(&mut self, patterns: I)
Replace the whitelist patterns (compiled once).
Sourcepub fn set_blacklist_patterns<I, S>(&mut self, patterns: I)
pub fn set_blacklist_patterns<I, S>(&mut self, patterns: I)
Replace the blacklist patterns (compiled once).
Sourcepub fn add_blacklist_pattern<S: Into<String>>(&mut self, pattern: S)
pub fn add_blacklist_pattern<S: Into<String>>(&mut self, pattern: S)
Add one pattern (cheap) and rebuild (call this sparingly).
Sourcepub fn add_blacklist_patterns<I, S>(&mut self, patterns: I)
pub fn add_blacklist_patterns<I, S>(&mut self, patterns: I)
Add many patterns and rebuild once.
Sourcepub fn clear_blacklist(&mut self)
pub fn clear_blacklist(&mut self)
Clear blacklist entirely.
Sourcepub fn set_blacklist_strict(&mut self, strict: bool)
pub fn set_blacklist_strict(&mut self, strict: bool)
Control precedence: when true, blacklist always wins.
Sourcepub fn add_whitelist_pattern<S: Into<String>>(&mut self, pattern: S)
pub fn add_whitelist_pattern<S: Into<String>>(&mut self, pattern: S)
Add one pattern (cheap) and rebuild (call this sparingly).
Sourcepub fn add_whitelist_patterns<I, S>(&mut self, patterns: I)
pub fn add_whitelist_patterns<I, S>(&mut self, patterns: I)
Add many patterns and rebuild once.
Sourcepub fn init_commands(&self) -> CommandChain
pub fn init_commands(&self) -> CommandChain
Commands to init the chain with.
Sourcepub fn poll(&mut self) -> Option<NetworkEvent>
pub fn poll(&mut self) -> Option<NetworkEvent>
The next event to handle.
Sourcepub fn extra_headers(&self) -> &HashMap<String, String>
pub fn extra_headers(&self) -> &HashMap<String, String>
Get the extra headers.
Sourcepub fn set_extra_headers(&mut self, headers: HashMap<String, String>)
pub fn set_extra_headers(&mut self, headers: HashMap<String, String>)
Set extra HTTP headers.
pub fn set_service_worker_enabled(&mut self, bypass: bool)
pub fn set_block_all(&mut self, block_all: bool)
pub fn set_request_interception(&mut self, enabled: bool)
pub fn set_cache_enabled(&mut self, enabled: bool)
Sourcepub fn enable_request_intercept(&mut self)
pub fn enable_request_intercept(&mut self)
Enable fetch interception.
Sourcepub fn disable_request_intercept(&mut self)
pub fn disable_request_intercept(&mut self)
Disable fetch interception.
pub fn update_protocol_cache_disabled(&mut self)
pub fn authenticate(&mut self, credentials: Credentials)
Sourcepub fn on_fetch_request_paused(&mut self, event: &EventRequestPaused)
pub fn on_fetch_request_paused(&mut self, event: &EventRequestPaused)
On fetch request paused interception.
Sourcepub fn has_target_domain(&self) -> bool
pub fn has_target_domain(&self) -> bool
Does the network manager have a target domain?
Sourcepub fn set_page_url(&mut self, page_target_url: String)
pub fn set_page_url(&mut self, page_target_url: String)
Set the target page url for tracking.
Sourcepub fn clear_target_domain(&mut self)
pub fn clear_target_domain(&mut self)
Clear the initial target domain on every navigation.
pub fn on_fetch_auth_required(&mut self, event: &EventAuthRequired)
Sourcepub fn set_offline_mode(&mut self, value: bool)
pub fn set_offline_mode(&mut self, value: bool)
Set the page offline network emulation condition.
Sourcepub fn on_request_will_be_sent(&mut self, event: &EventRequestWillBeSent)
pub fn on_request_will_be_sent(&mut self, event: &EventRequestWillBeSent)
Request interception doesn’t happen for data URLs with Network Service.
Sourcepub fn on_request_served_from_cache(
&mut self,
event: &EventRequestServedFromCache,
)
pub fn on_request_served_from_cache( &mut self, event: &EventRequestServedFromCache, )
The request was served from the cache.
Sourcepub fn on_response_received(&mut self, event: &EventResponseReceived)
pub fn on_response_received(&mut self, event: &EventResponseReceived)
On network response received.
Sourcepub fn on_network_loading_finished(&mut self, event: &EventLoadingFinished)
pub fn on_network_loading_finished(&mut self, event: &EventLoadingFinished)
On network loading finished.
Sourcepub fn on_network_loading_failed(&mut self, event: &EventLoadingFailed)
pub fn on_network_loading_failed(&mut self, event: &EventLoadingFailed)
On network loading failed.