@@ -5,6 +5,7 @@ use std::convert::{Infallible, TryFrom};
5
5
6
6
use std:: fmt:: Debug ;
7
7
use std:: net:: SocketAddr ;
8
+ use std:: sync:: Arc ;
8
9
9
10
use async_h1:: client;
10
11
use async_std:: net:: TcpStream ;
@@ -45,7 +46,7 @@ pub struct H1Client {
45
46
#[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
46
47
https_pools : HttpsPool ,
47
48
max_concurrent_connections : usize ,
48
- config : Config ,
49
+ config : Arc < Config > ,
49
50
}
50
51
51
52
impl Debug for H1Client {
@@ -104,7 +105,7 @@ impl H1Client {
104
105
#[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
105
106
https_pools : DashMap :: new ( ) ,
106
107
max_concurrent_connections : DEFAULT_MAX_CONCURRENT_CONNECTIONS ,
107
- config : Config :: default ( ) ,
108
+ config : Arc :: new ( Config :: default ( ) ) ,
108
109
}
109
110
}
110
111
@@ -115,7 +116,7 @@ impl H1Client {
115
116
#[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
116
117
https_pools : DashMap :: new ( ) ,
117
118
max_concurrent_connections : max,
118
- config : Config :: default ( ) ,
119
+ config : Arc :: new ( Config :: default ( ) ) ,
119
120
}
120
121
}
121
122
}
@@ -276,15 +277,15 @@ impl HttpClient for H1Client {
276
277
///
277
278
/// Config options may not impact existing connections.
278
279
fn set_config ( & mut self , config : Config ) -> http_types:: Result < ( ) > {
279
- self . config = config;
280
+ self . config = Arc :: new ( config) ;
280
281
281
282
Ok ( ( ) )
282
283
}
283
284
284
285
#[ cfg( feature = "unstable-config" ) ]
285
286
/// Get the current configuration.
286
287
fn config ( & self ) -> & Config {
287
- & self . config
288
+ & * self . config
288
289
}
289
290
}
290
291
@@ -298,7 +299,7 @@ impl TryFrom<Config> for H1Client {
298
299
#[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
299
300
https_pools : DashMap :: new ( ) ,
300
301
max_concurrent_connections : DEFAULT_MAX_CONCURRENT_CONNECTIONS ,
301
- config,
302
+ config : Arc :: new ( config ) ,
302
303
} )
303
304
}
304
305
}
0 commit comments