Skip to content

Commit 98e7ac1

Browse files
authored
Merge pull request #2953 from hi-rustin/rustin-patch-user-agent
Add the user agent for http requests
2 parents 84e4639 + 932751e commit 98e7ac1

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ APIs, we should behave well if we can.
152152
Producing the final release artifacts is a bit involved because of the way
153153
Rustup is distributed. The steps for a release are:
154154

155-
1. Update all `Cargo.toml` to have the new version
155+
1. Update `Cargo.toml` and `download/Cargo.toml`to have the same new version
156156
(optionally make a commit)
157157
2. Run `cargo build` and review `Cargo.lock` changes
158158
if all looks well, make a commit

Cargo.lock

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

download/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ authors = ["Brian Anderson <[email protected]>"]
44
edition = "2021"
55
license = "MIT/Apache-2.0"
66
name = "download"
7-
version = "0.6.9"
7+
version = "1.24.3"
88

99
[features]
1010

download/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ use url::Url;
1010
mod errors;
1111
pub use crate::errors::*;
1212

13+
/// User agent header value for HTTP request.
14+
/// See: https://github.com/rust-lang/rustup/issues/2860.
15+
const USER_AGENT: &str = concat!("rustup/", env!("CARGO_PKG_VERSION"));
16+
1317
#[derive(Debug, Copy, Clone)]
1418
pub enum Backend {
1519
Curl,
@@ -164,6 +168,7 @@ pub mod curl {
164168

165169
handle.url(url.as_ref())?;
166170
handle.follow_location(true)?;
171+
handle.useragent(super::USER_AGENT)?;
167172

168173
if resume_from > 0 {
169174
handle.resume_from(resume_from)?;
@@ -303,6 +308,7 @@ pub mod reqwest_be {
303308
fn client_generic() -> ClientBuilder {
304309
Client::builder()
305310
.gzip(false)
311+
.user_agent(super::USER_AGENT)
306312
.proxy(Proxy::custom(env_proxy))
307313
.timeout(Duration::from_secs(30))
308314
}

0 commit comments

Comments
 (0)