pub fn parse_find_proxy_result(result: &str) -> Result<Vec<ProxyStep>, Error>pac only.Expand description
Parse a FindProxyForURL return string into an ordered fallback chain.
Tokens are separated by ; or newlines; newline separation is specific to this crate
and differs from Chromium. Keywords are case-insensitive: DIRECT;
PROXY/HTTP→ProxyStep::Http; HTTPS→HTTPS; SOCKS/SOCKS4→SOCKS4;
SOCKS5→ProxyScheme::Socks5h (remote DNS). An address without a port uses
ProxyScheme::default_port for the keyword’s scheme. Addresses must be bare
authorities: /, ? or #, including in scheme://, invalidates the whole candidate.
Bad tokens are skipped, repeats collapse, and embedded credentials are dropped. An empty
usable chain returns Error::PacInvalidResult. Words are split at ASCII whitespace
only, so a no-break space or a vertical tab stays inside a word and spoils it. An IPv6
address without a port can go without brackets (PROXY ::1). The chain keeps its first
64 steps and drops the rest, an explicit DIRECT among them.
let steps = parse_find_proxy_result("PROXY a:1; SOCKS5 b:2; DIRECT")?;
assert_eq!(steps.len(), 3);
assert_eq!(steps[0].endpoint().unwrap().authority(), "a:1");
assert_eq!(steps[1].scheme(), Some("socks5"));
assert_eq!(steps[1].to_url().unwrap().as_str(), "socks5h://b:2");
assert!(steps[2].is_direct());§Errors
Error::PacInvalidResult when no candidate in the string could be understood,
including the empty string.