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.
;-separated tokens, and newlines too — that part is this crate’s, not Chromium’s.
Keywords case-insensitive:
DIRECT; PROXY/HTTP→ProxyStep::Http; HTTPS→HTTPS; SOCKS/SOCKS4→SOCKS4;
SOCKS5→ProxyScheme::Socks5h (remote DNS). An address with no port of its own gets
ProxyScheme::default_port for the scheme the keyword named, rather than a second
table of ports here. The address is a bare authority, so a /, ? or # in it — a
scheme:// included — makes the candidate one of the bad ones rather than something to
trim. Bad tokens skipped; repeats collapse; embedded credentials dropped; empty usable
chain → Error::PacInvalidResult.
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.