pub trait RequestMutator:
Send
+ Sync
+ 'static {
// Required method
fn mutate(&self, proxy_url: &str, req: Request) -> Request;
}Expand description
Mutates a cloned request just before it is dispatched through a specific proxy.
The scheduler calls mutate after try_clone() and before client.execute(),
giving implementations a chance to inject per-proxy request headers such as
cookies obtained from a prior WAF challenge solve.
§Example
ⓘ
use scatter_proxy::RequestMutator;
use std::sync::Arc;
struct CookieMutator {
proxy_manager: Arc<scatter_proxy::ProxyManager>,
}
impl RequestMutator for CookieMutator {
fn mutate(&self, proxy_url: &str, mut req: reqwest::Request) -> reqwest::Request {
if let Some(cookie_val) = self.proxy_manager.get_cookie(proxy_url) {
let header_val = format!("acw_sc__v2={cookie_val}");
if let Ok(v) = header_val.parse() {
req.headers_mut().insert(reqwest::header::COOKIE, v);
}
}
req
}
}