@@ -12,7 +12,19 @@ pub use crate::errors::*;
12
12
13
13
/// User agent header value for HTTP request.
14
14
/// 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)" ) ;
16
28
17
29
#[ derive( Debug , Copy , Clone ) ]
18
30
pub enum Backend {
@@ -175,7 +187,7 @@ pub mod curl {
175
187
176
188
handle. url ( url. as_ref ( ) ) ?;
177
189
handle. follow_location ( true ) ?;
178
- handle. useragent ( super :: USER_AGENT ) ?;
190
+ handle. useragent ( super :: CURL_USER_AGENT ) ?;
179
191
180
192
if resume_from > 0 {
181
193
handle. resume_from ( resume_from) ?;
@@ -322,14 +334,18 @@ pub mod reqwest_be {
322
334
fn client_generic ( ) -> ClientBuilder {
323
335
Client :: builder ( )
324
336
. gzip ( false )
325
- . user_agent ( super :: USER_AGENT )
326
337
. proxy ( Proxy :: custom ( env_proxy) )
327
338
. timeout ( Duration :: from_secs ( 30 ) )
328
339
}
329
340
330
341
#[ cfg( feature = "reqwest-rustls-tls" ) ]
331
342
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
+ } ;
333
349
334
350
// woah, an unwrap?!
335
351
// It's OK. This is the same as what is happening in curl.
@@ -342,7 +358,11 @@ pub mod reqwest_be {
342
358
343
359
#[ cfg( feature = "reqwest-default-tls" ) ]
344
360
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
+ } ;
346
366
347
367
// woah, an unwrap?!
348
368
// It's OK. This is the same as what is happening in curl.
0 commit comments