Skip to content

Commit

Permalink
Merge pull request #2953 from hi-rustin/rustin-patch-user-agent
Browse files Browse the repository at this point in the history
Add the user agent for http requests
  • Loading branch information
kinnison authored Mar 10, 2022
2 parents 84e4639 + 932751e commit 98e7ac1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ APIs, we should behave well if we can.
Producing the final release artifacts is a bit involved because of the way
Rustup is distributed. The steps for a release are:

1. Update all `Cargo.toml` to have the new version
1. Update `Cargo.toml` and `download/Cargo.toml`to have the same new version
(optionally make a commit)
2. Run `cargo build` and review `Cargo.lock` changes
if all looks well, make a commit
Expand Down
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["Brian Anderson <[email protected]>"]
edition = "2021"
license = "MIT/Apache-2.0"
name = "download"
version = "0.6.9"
version = "1.24.3"

[features]

Expand Down
6 changes: 6 additions & 0 deletions download/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ use url::Url;
mod errors;
pub use crate::errors::*;

/// User agent header value for HTTP request.
/// See: https://github.com/rust-lang/rustup/issues/2860.
const USER_AGENT: &str = concat!("rustup/", env!("CARGO_PKG_VERSION"));

#[derive(Debug, Copy, Clone)]
pub enum Backend {
Curl,
Expand Down Expand Up @@ -164,6 +168,7 @@ pub mod curl {

handle.url(url.as_ref())?;
handle.follow_location(true)?;
handle.useragent(super::USER_AGENT)?;

if resume_from > 0 {
handle.resume_from(resume_from)?;
Expand Down Expand Up @@ -303,6 +308,7 @@ pub mod reqwest_be {
fn client_generic() -> ClientBuilder {
Client::builder()
.gzip(false)
.user_agent(super::USER_AGENT)
.proxy(Proxy::custom(env_proxy))
.timeout(Duration::from_secs(30))
}
Expand Down

0 comments on commit 98e7ac1

Please sign in to comment.