@@ -12,7 +12,19 @@ pub use crate::errors::*;
1212
1313/// User agent header value for HTTP request.
1414/// See: https://github.com/rust-lang/rustup/issues/2860.
15- const USER_AGENT : & str = concat ! ( "rustup/" , env!( "CARGO_PKG_VERSION" ) ) ;
15+ #[ cfg( feature = "curl-backend" ) ]
16+ const CURL_USER_AGENT : & str = concat ! ( "rustup/" , env!( "CARGO_PKG_VERSION" ) , " (curl)" ) ;
17+
18+ #[ cfg( feature = "reqwest-default-tls" ) ]
19+ const REQWEST_DEFAULT_TLS_USER_AGENT : & str = concat ! (
20+ "rustup/" ,
21+ env!( "CARGO_PKG_VERSION" ) ,
22+ " (reqwest; default-tls)"
23+ ) ;
24+
25+ #[ cfg( feature = "reqwest-rustls-tls" ) ]
26+ const REQWEST_RUSTLS_TLS_USER_AGENT : & str =
27+ concat ! ( "rustup/" , env!( "CARGO_PKG_VERSION" ) , " (reqwest; rustls)" ) ;
1628
1729#[ derive( Debug , Copy , Clone ) ]
1830pub enum Backend {
@@ -175,7 +187,7 @@ pub mod curl {
175187
176188 handle. url ( url. as_ref ( ) ) ?;
177189 handle. follow_location ( true ) ?;
178- handle. useragent ( super :: USER_AGENT ) ?;
190+ handle. useragent ( super :: CURL_USER_AGENT ) ?;
179191
180192 if resume_from > 0 {
181193 handle. resume_from ( resume_from) ?;
@@ -322,14 +334,18 @@ pub mod reqwest_be {
322334 fn client_generic ( ) -> ClientBuilder {
323335 Client :: builder ( )
324336 . gzip ( false )
325- . user_agent ( super :: USER_AGENT )
326337 . proxy ( Proxy :: custom ( env_proxy) )
327338 . timeout ( Duration :: from_secs ( 30 ) )
328339 }
329340
330341 #[ cfg( feature = "reqwest-rustls-tls" ) ]
331342 static CLIENT_RUSTLS_TLS : Lazy < Client > = Lazy :: new ( || {
332- let catcher = || client_generic ( ) . use_rustls_tls ( ) . build ( ) ;
343+ let catcher = || {
344+ client_generic ( )
345+ . use_rustls_tls ( )
346+ . user_agent ( super :: REQWEST_RUSTLS_TLS_USER_AGENT )
347+ . build ( )
348+ } ;
333349
334350 // woah, an unwrap?!
335351 // It's OK. This is the same as what is happening in curl.
@@ -342,7 +358,11 @@ pub mod reqwest_be {
342358
343359 #[ cfg( feature = "reqwest-default-tls" ) ]
344360 static CLIENT_DEFAULT_TLS : Lazy < Client > = Lazy :: new ( || {
345- let catcher = || client_generic ( ) . build ( ) ;
361+ let catcher = || {
362+ client_generic ( )
363+ . user_agent ( super :: REQWEST_DEFAULT_TLS_USER_AGENT )
364+ . build ( )
365+ } ;
346366
347367 // woah, an unwrap?!
348368 // It's OK. This is the same as what is happening in curl.
0 commit comments