Skip to main content

resolve

Function resolve 

Source
pub fn resolve(config: &ProxyConfig, url: &Url) -> Result<Vec<ProxyStep>, Error>
Available on crate feature resolve only.
Expand description

Routing decisions, behind the resolve feature (on by default). Decide how to reach url under config.

Never empty, and decided in this order. Pac/WPAD → Error::PacNotSupported, hostless URLs included: under an auto-config mode this entry point can answer no URL at all, so singling out mailto: for Direct while erroring on every other URL would be the stranger contract. resolve_with_pac and WinHttpPacResolver::resolve_config do take hostless first — they can answer the rest. Then, under a manual mode, hostless or bypass → Direct; else entry_for / websocket_entry for ws/wss.

The list transcribes what the configuration says; it never invents alternatives. A single manual entry yields a single step, and a versionless socks host is one step at this crate’s assumed version rather than one step per version a caller might try.

The transcription is only ever as strong as the source that produced the mode, and one source is weaker than it looks: a ProxyMode::Direct carrying ProxyConfigSource::Portal says the portal had no proxy for a fixed probe host, not for url — that variant’s doc has the reason. Nothing here can narrow the gap, because the snapshot no longer knows what was asked.

§Errors

Error::PacNotSupported for auto-config modes, and Error::ProxyEntryUnusable where the only entry that would have covered url was dropped — reporting that is not the same as answering Direct.

let mode = parse::windows_manual("http=proxy.corp:8080", "<local>;*.corp.example");
let config = ProxyConfig::from_source(ProxyConfigSource::Registry, mode);

let steps = resolve(&config, &Url::parse("http://example.net/x").unwrap())?;
assert_eq!(steps[0].endpoint().unwrap().authority(), "proxy.corp:8080");

let steps = resolve(&config, &Url::parse("http://api.corp.example/x").unwrap())?;
assert_eq!(steps, vec![ProxyStep::Direct]);