use crate::context::CargoHttpConfig;
use crate::context::GlobalContext;
const LIBCURL_HTTP_PROXY_ENVS: [&str; 4] =
["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"];
pub fn http_proxy(http: &CargoHttpConfig) -> Option<String> {
if let Some(s) = &http.proxy {
return Some(s.into());
}
git2::Config::open_default()
.and_then(|cfg| cfg.get_string("http.proxy"))
.ok()
}
pub fn http_proxy_exists(http: &CargoHttpConfig, gctx: &GlobalContext) -> bool {
http_proxy(http).is_some()
|| LIBCURL_HTTP_PROXY_ENVS
.iter()
.any(|v| gctx.get_env(v).is_ok())
}