Don't include the version of rust-tuf in the user agent
The fuchsia build system does not use cargo to build libraries, and at
the moment it is unable to convey environment variables. As a stopgap,
this removes the use of `env!("CARGO_PKG_VERSION")` until we can add
support for this.
Change-Id: If35a244533c95ba2a7bedff2c45b5d33d7a3a84b
diff --git a/src/client.rs b/src/client.rs
index a4032ad..bffcf92 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -33,7 +33,7 @@
//! url::Url::parse("https://static.rust-lang.org/").unwrap(),
//! HttpClient::new(),
//! )
-//! .user_agent_prefix("rustup/1.4.0")
+//! .user_agent("rustup/1.4.0")
//! .build();
//!
//! let mut client = await!(Client::with_root_pinned(
diff --git a/src/repository.rs b/src/repository.rs
index 5d1babc..dfa68ba 100644
--- a/src/repository.rs
+++ b/src/repository.rs
@@ -263,7 +263,7 @@
url: Url,
client: Client<C>,
interchange: PhantomData<D>,
- user_agent_prefix: Option<String>,
+ user_agent: Option<String>,
metadata_prefix: Option<Vec<String>>,
min_bytes_per_second: u32,
}
@@ -279,7 +279,7 @@
url: url,
client: client,
interchange: PhantomData,
- user_agent_prefix: None,
+ user_agent: None,
metadata_prefix: None,
min_bytes_per_second: 4096,
}
@@ -290,8 +290,8 @@
/// Callers *should* include a custom User-Agent prefix to help maintainers of TUF repositories
/// keep track of which client versions exist in the field.
///
- pub fn user_agent_prefix<T: Into<String>>(mut self, user_agent_prefix: T) -> Self {
- self.user_agent_prefix = Some(user_agent_prefix.into());
+ pub fn user_agent<T: Into<String>>(mut self, user_agent: T) -> Self {
+ self.user_agent = Some(user_agent.into());
self
}
@@ -313,9 +313,9 @@
/// Build a `HttpRepository`.
pub fn build(self) -> HttpRepository<C, D> {
- let user_agent = match self.user_agent_prefix {
- Some(ua) => format!("{} (rust-tuf/{})", ua, env!("CARGO_PKG_VERSION")),
- None => format!("rust-tuf/{}", env!("CARGO_PKG_VERSION")),
+ let user_agent = match self.user_agent {
+ Some(user_agent) => user_agent,
+ None => "rust-tuf".into(),
};
HttpRepository {