let timeout = http_timeout(config)?;
let cainfo = config.get_path("http.cainfo")?;
let check_revoke = config.get_bool("http.check-revoke")?;
+ let user_agent = config.get_string("http.user-agent")?;
- Ok(proxy_exists || timeout.is_some() || cainfo.is_some() || check_revoke.is_some())
+ Ok(
+ proxy_exists || timeout.is_some() || cainfo.is_some() || check_revoke.is_some()
+ || user_agent.is_some(),
+ )
}
/// Configure a libcurl http handle with the defaults options for Cargo
handle.connect_timeout(Duration::new(30, 0))?;
handle.low_speed_limit(10 /* bytes per second */)?;
handle.low_speed_time(Duration::new(30, 0))?;
- handle.useragent(&version().to_string())?;
if let Some(proxy) = http_proxy(config)? {
handle.proxy(&proxy)?;
}
handle.connect_timeout(Duration::new(timeout as u64, 0))?;
handle.low_speed_time(Duration::new(timeout as u64, 0))?;
}
+ if let Some(user_agent) = config.get_string("http.user-agent")? {
+ handle.useragent(&user_agent.val)?;
+ } else {
+ handle.useragent(&version().to_string())?;
+ }
Ok(())
}
);
}
+#[test]
+fn bad6() {
+ let p = project("foo")
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ "#,
+ )
+ .file("src/lib.rs", "")
+ .file(
+ ".cargo/config",
+ r#"
+ [http]
+ user-agent = true
+ "#,
+ )
+ .build();
+ Package::new("foo", "1.0.0").publish();
+
+ assert_that(
+ p.cargo("publish").arg("-v"),
+ execs().with_status(101).with_stderr(
+ "\
+error: failed to update registry [..]
+
+Caused by:
+ invalid configuration for key `http.user-agent`
+expected a string, but found a boolean for `http.user-agent` in [..]config
+",
+ ),
+ );
+}
+
#[test]
fn bad_cargo_config_jobs() {
let p = project("foo")