pub fn resolve_with_pac(
config: &ProxyConfig,
url: &Url,
script: Option<&PacScript>,
policy: &PacPolicy,
) -> Result<Vec<ProxyStep>, Error>Available on crate features
pac and resolve only.Expand description
Routing decisions that may need a PAC script, behind the pac feature (off by
default).
Like resolve, but evaluates PAC when the mode requires it.
For ProxyMode::Direct and ProxyMode::Manual, this agrees with resolve exactly
and script is ignored. PacInline: body from script or mode. Pac: Some(script)
or Error::PacFetchRequired. WpadAutoDetect: Some(script) or
Error::PacNotSupported. Never downloads; hostless โ Direct; no bypass in PAC modes.
ยงErrors
Error::PacFetchRequired, Error::PacNotSupported, pac::evaluate,
and โ because Direct and Manual are handed straight to resolve โ
Error::ProxyEntryUnusable.
use proxy_watch::pac::PacPolicy;
use proxy_watch::{Error, ProxyConfig, ProxyConfigSource, ProxyMode, Url, resolve_with_pac};
let mode = ProxyMode::pac(Url::parse("http://wpad.corp/proxy.pac").unwrap());
let config = ProxyConfig::from_source(ProxyConfigSource::Registry, mode);
let url = Url::parse("http://example.net/").unwrap();
let Error::PacFetchRequired { url: wanted } =
resolve_with_pac(&config, &url, None, &PacPolicy::new()).unwrap_err()
else { panic!() };
assert_eq!(wanted.as_str(), "http://wpad.corp/proxy.pac");