@@ -5,6 +5,7 @@ use std::convert::{Infallible, TryFrom};
55
66use std:: fmt:: Debug ;
77use std:: net:: SocketAddr ;
8+ use std:: sync:: Arc ;
89
910use async_h1:: client;
1011use async_std:: net:: TcpStream ;
@@ -45,7 +46,7 @@ pub struct H1Client {
4546 #[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
4647 https_pools : HttpsPool ,
4748 max_concurrent_connections : usize ,
48- config : Config ,
49+ config : Arc < Config > ,
4950}
5051
5152impl Debug for H1Client {
@@ -104,7 +105,7 @@ impl H1Client {
104105 #[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
105106 https_pools : DashMap :: new ( ) ,
106107 max_concurrent_connections : DEFAULT_MAX_CONCURRENT_CONNECTIONS ,
107- config : Config :: default ( ) ,
108+ config : Arc :: new ( Config :: default ( ) ) ,
108109 }
109110 }
110111
@@ -115,7 +116,7 @@ impl H1Client {
115116 #[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
116117 https_pools : DashMap :: new ( ) ,
117118 max_concurrent_connections : max,
118- config : Config :: default ( ) ,
119+ config : Arc :: new ( Config :: default ( ) ) ,
119120 }
120121 }
121122}
@@ -276,15 +277,15 @@ impl HttpClient for H1Client {
276277 ///
277278 /// Config options may not impact existing connections.
278279 fn set_config ( & mut self , config : Config ) -> http_types:: Result < ( ) > {
279- self . config = config;
280+ self . config = Arc :: new ( config) ;
280281
281282 Ok ( ( ) )
282283 }
283284
284285 #[ cfg( feature = "unstable-config" ) ]
285286 /// Get the current configuration.
286287 fn config ( & self ) -> & Config {
287- & self . config
288+ & * self . config
288289 }
289290}
290291
@@ -298,7 +299,7 @@ impl TryFrom<Config> for H1Client {
298299 #[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
299300 https_pools : DashMap :: new ( ) ,
300301 max_concurrent_connections : DEFAULT_MAX_CONCURRENT_CONNECTIONS ,
301- config,
302+ config : Arc :: new ( config ) ,
302303 } )
303304 }
304305}
0 commit comments