Skip to main content

proxy_server

Function proxy_server 

Source
pub fn proxy_server(spec: &str) -> HashMap<Scheme, ProxyEntry>
Expand description

Parse Windows ProxyServer (WINHTTP_CURRENT_USER_IE_PROXY_CONFIG).

Bare host:portScheme::All; or http=/https=/ftp=/socks=/all=. Missing port → WINDOWS_DEFAULT_PORT (1080 for bare socks=). Empty scheme → ProxyEntry::Disabled. Bad tokens skipped; recorded on windows_manual. A scheme named twice keeps the last token that was not skipped, so a bad last spelling leaves the earlier one standing. A socks= entry also fills every scheme the string left unset — the last two examples below are that rule and its limit.

let map = parse::proxy_server("http=h:8080;https=h");
assert_eq!(map[&Scheme::Http].endpoint().unwrap().port, 8080);
assert_eq!(map[&Scheme::Https].endpoint().unwrap().port, 80);

let map = parse::proxy_server("socks=127.0.0.1:1080");
assert_eq!(map[&Scheme::Http].endpoint().unwrap().authority(), "127.0.0.1:1080");
assert_eq!(
    map[&Scheme::Http].endpoint().unwrap().scheme_hint,
    Some(ProxyScheme::Socks4)
);
let map = parse::proxy_server("http=h1:8080;socks=127.0.0.1:1080");
assert_eq!(map[&Scheme::Http].endpoint().unwrap().authority(), "h1:8080");