1- use std:: { convert :: identity , path:: Path , time:: Duration } ;
1+ use std:: { path:: Path , time:: Duration } ;
22
33use anyhow:: { anyhow, ensure} ;
44use humantime_serde:: re:: humantime;
@@ -8,20 +8,21 @@ use tokio::process::Command;
88use crate :: prop;
99
1010pub fn reqwest_client ( ) -> anyhow:: Result < reqwest:: Client > {
11- reqwest_client_with ( identity )
11+ reqwest_client_with ( |b , _| b )
1212}
1313
1414pub fn reqwest_client_with (
15- configure : impl FnOnce ( reqwest:: ClientBuilder ) -> reqwest:: ClientBuilder ,
15+ configure : impl FnOnce ( reqwest:: ClientBuilder , & mut HeaderMap ) -> reqwest:: ClientBuilder ,
1616) -> anyhow:: Result < reqwest:: Client > {
17+ let mut headers = HeaderMap :: from_iter ( [ (
18+ header:: USER_AGENT ,
19+ HeaderValue :: from_str ( & prop:: UserAgent :: Logo . as_str ( ) ) . unwrap ( ) ,
20+ ) ] ) ;
1721 configure (
18- reqwest:: ClientBuilder :: new ( )
19- . timeout ( Duration :: from_secs ( 60 ) * 3 )
20- . default_headers ( HeaderMap :: from_iter ( [ (
21- header:: USER_AGENT ,
22- HeaderValue :: from_str ( & prop:: UserAgent :: Logo . as_str ( ) ) . unwrap ( ) ,
23- ) ] ) ) ,
22+ reqwest:: ClientBuilder :: new ( ) . timeout ( Duration :: from_secs ( 60 ) * 3 ) ,
23+ & mut headers,
2424 )
25+ . default_headers ( headers)
2526 . build ( )
2627 . map_err ( |err| anyhow ! ( "failed to build reqwest client: {err}" ) )
2728}
0 commit comments