Function cargo_update::ops::find_proxy[][src]

pub fn find_proxy(crates_file: &Path) -> Option<String>
Expand description

Check if there’s a proxy specified to be used.

Look for http.proxy key in the config file parallel to the specified crates file.

Then look for git’s http.proxy.

Then for the http_proxy, HTTP_PROXY, https_proxy, and HTTPS_PROXY environment variables, in that order.

Based on Cargo’s http_proxy_exists() and http_proxy()

If a proxy is specified, but an empty string, treat it as unspecified.

Examples

match find_proxy(&crates_file) {
    Some(proxy) => println!("Proxy found at {}", proxy),
    None => println!("No proxy detected"),
}