@@ -12,7 +12,14 @@ 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
+ const CURL_USER_AGENT : & str = concat ! ( "rustup/" , env!( "CARGO_PKG_VERSION" ) , " (curl)" ) ;
16
+ const REQWEST_DEFAULT_TLS_USER_AGENT : & str = concat ! (
17
+ "rustup/" ,
18
+ env!( "CARGO_PKG_VERSION" ) ,
19
+ " (reqwest; default-tls)"
20
+ ) ;
21
+ const REQWEST_RUSTLS_TLS_USER_AGENT : & str =
22
+ concat ! ( "rustup/" , env!( "CARGO_PKG_VERSION" ) , " (reqwest; rustls)" ) ;
16
23
17
24
#[ derive( Debug , Copy , Clone ) ]
18
25
pub enum Backend {
@@ -175,7 +182,7 @@ pub mod curl {
175
182
176
183
handle. url ( url. as_ref ( ) ) ?;
177
184
handle. follow_location ( true ) ?;
178
- handle. useragent ( super :: USER_AGENT ) ?;
185
+ handle. useragent ( super :: CURL_USER_AGENT ) ?;
179
186
180
187
if resume_from > 0 {
181
188
handle. resume_from ( resume_from) ?;
@@ -322,14 +329,18 @@ pub mod reqwest_be {
322
329
fn client_generic ( ) -> ClientBuilder {
323
330
Client :: builder ( )
324
331
. gzip ( false )
325
- . user_agent ( super :: USER_AGENT )
326
332
. proxy ( Proxy :: custom ( env_proxy) )
327
333
. timeout ( Duration :: from_secs ( 30 ) )
328
334
}
329
335
330
336
#[ cfg( feature = "reqwest-rustls-tls" ) ]
331
337
static CLIENT_RUSTLS_TLS : Lazy < Client > = Lazy :: new ( || {
332
- let catcher = || client_generic ( ) . use_rustls_tls ( ) . build ( ) ;
338
+ let catcher = || {
339
+ client_generic ( )
340
+ . use_rustls_tls ( )
341
+ . user_agent ( super :: REQWEST_RUSTLS_TLS_USER_AGENT )
342
+ . build ( )
343
+ } ;
333
344
334
345
// woah, an unwrap?!
335
346
// It's OK. This is the same as what is happening in curl.
@@ -342,7 +353,11 @@ pub mod reqwest_be {
342
353
343
354
#[ cfg( feature = "reqwest-default-tls" ) ]
344
355
static CLIENT_DEFAULT_TLS : Lazy < Client > = Lazy :: new ( || {
345
- let catcher = || client_generic ( ) . build ( ) ;
356
+ let catcher = || {
357
+ client_generic ( )
358
+ . user_agent ( super :: REQWEST_DEFAULT_TLS_USER_AGENT )
359
+ . build ( )
360
+ } ;
346
361
347
362
// woah, an unwrap?!
348
363
// It's OK. This is the same as what is happening in curl.
0 commit comments