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). Routing decisions, behind the resolve feature (on by default). Routing decisions, behind the resolve feature (on by default). Decide how to reach url under config.

The result is never empty. Pac/WPAD returns Error::PacNotSupported, including for hostless URLs, because this entry point cannot resolve any URL under an auto-config mode. resolve_with_pac and the native resolvers’ resolve_config handle hostless URLs first because they can resolve the remaining URLs. Under a manual mode, hostless or bypassed URLs return Direct; otherwise resolution uses entry_for, or 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.

A ProxyMode::Direct carrying ProxyConfigSource::Portal reports that the portal has no proxy for a fixed probe host, not for url; see that variant’s documentation for the reason. The snapshot does not retain the probe URL, so resolution cannot account for this difference.

§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]);