}
fn init_git_transports(config: &Config) {
- // Only use a custom transport if a proxy is configured, right now libgit2
- // doesn't support proxies and we have to use a custom transport in this
- // case. The custom transport, however, is not as well battle-tested.
- match cargo::ops::http_proxy_exists(config) {
+ // Only use a custom transport if any HTTP options are specified,
+ // such as proxies or custom certificate authorities. The custom
+ // transport, however, is not as well battle-tested.
+
+ match cargo::ops::needs_custom_http_transport(config) {
Ok(true) => {}
_ => return,
}
pub use self::cargo_test::{run_tests, run_benches, TestOptions};
pub use self::cargo_package::{package, PackageOpts};
pub use self::registry::{publish, registry_configuration, RegistryConfig};
-pub use self::registry::{registry_login, search, http_proxy_exists, http_handle};
+pub use self::registry::{registry_login, search, needs_custom_http_transport, http_handle};
pub use self::registry::{modify_owners, yank, OwnersOptions, PublishOpts};
pub use self::registry::configure_http_handle;
pub use self::cargo_fetch::fetch;
Ok(handle)
}
+pub fn needs_custom_http_transport(config: &Config) -> CargoResult<bool> {
+ let proxy_exists = http_proxy_exists(config)?;
+ let timeout = http_timeout(config)?;
+ let cainfo = config.get_path("http.cainfo")?;
+ let check_revoke = config.get_bool("http.check-revoke")?;
+
+ Ok(proxy_exists || timeout.is_some() || cainfo.is_some() || check_revoke.is_some())
+}
+
/// Configure a libcurl http handle with the defaults options for Cargo
pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<()> {
// The timeout option for libcurl by default times out the entire transfer,
/// * `HTTP_PROXY` env var
/// * `https_proxy` env var
/// * `HTTPS_PROXY` env var
-pub fn http_proxy_exists(config: &Config) -> CargoResult<bool> {
+fn http_proxy_exists(config: &Config) -> CargoResult<bool> {
if http_proxy(config)?.is_some() {
Ok(true)
} else {
}
}
-pub fn http_timeout(config: &Config) -> CargoResult<Option<i64>> {
+fn http_timeout(config: &Config) -> CargoResult<Option<i64>> {
if let Some(s) = config.get_i64("http.timeout")? {
return Ok(Some(s.val))
}