pub use self::registry::{publish, registry_configuration, RegistryConfig};
pub use self::registry::{registry_login, search, http_proxy_exists, http_handle};
pub use self::registry::{modify_owners, yank, OwnersOptions, PublishOpts};
+pub use self::registry::configure_http_handle;
pub use self::cargo_fetch::fetch;
pub use self::cargo_pkgid::pkgid;
pub use self::resolve::{resolve_ws, resolve_ws_precisely, resolve_with_previous};
// connect phase as well as a "low speed" timeout so if we don't receive
// many bytes in a large-ish period of time then we time out.
let mut handle = Easy::new();
+ configure_http_handle(config, &mut handle)?;
+ Ok(handle)
+}
+
+/// 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,
+ // but we probably don't want this. Instead we only set timeouts for the
+ // connect phase as well as a "low speed" timeout so if we don't receive
+ // many bytes in a large-ish period of time then we time out.
handle.connect_timeout(Duration::new(30, 0))?;
handle.low_speed_limit(10 /* bytes per second */)?;
handle.low_speed_time(Duration::new(30, 0))?;
handle.connect_timeout(Duration::new(timeout as u64, 0))?;
handle.low_speed_time(Duration::new(timeout as u64, 0))?;
}
- Ok(handle)
+ Ok(())
}
/// Find an explicit HTTP proxy if one is available.
use serde_json;
use core::{PackageId, SourceId};
-use ops;
use sources::git;
use sources::registry::{RegistryData, RegistryConfig, INDEX_LOCK};
use util::network;
//
// This way if there's a problem the error gets printed before we even
// hit the index, which may not actually read this configuration.
- ops::http_handle(self.config)?;
+ self.config.http()?;
self.repo()?;
self.head.set(None);
let http = self.easy.get_or_try_init(|| {
ops::http_handle(self).map(RefCell::new)
})?;
- http.borrow_mut().reset();
+ {
+ let mut http = http.borrow_mut();
+ http.reset();
+ ops::configure_http_handle(self, &mut http)?;
+ }
Ok(http)
}
}