@@ -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 {
@@ -89,7 +90,7 @@ impl Debug for H1Client {
8990
9091 #[ cfg( not( feature = "rustls" ) ) ]
9192 {
92- dbg_struct. field ( "config" , & self . config ) ;
93+ dbg_struct. field ( "config" , & * self . config ) ;
9394 }
9495
9596 dbg_struct. finish ( )
@@ -110,7 +111,7 @@ impl H1Client {
110111 #[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
111112 https_pools : DashMap :: new ( ) ,
112113 max_concurrent_connections : DEFAULT_MAX_CONCURRENT_CONNECTIONS ,
113- config : Config :: default ( ) ,
114+ config : Arc :: new ( Config :: default ( ) ) ,
114115 }
115116 }
116117
@@ -121,7 +122,7 @@ impl H1Client {
121122 #[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
122123 https_pools : DashMap :: new ( ) ,
123124 max_concurrent_connections : max,
124- config : Config :: default ( ) ,
125+ config : Arc :: new ( Config :: default ( ) ) ,
125126 }
126127 }
127128}
@@ -282,15 +283,15 @@ impl HttpClient for H1Client {
282283 ///
283284 /// Config options may not impact existing connections.
284285 fn set_config ( & mut self , config : Config ) -> http_types:: Result < ( ) > {
285- self . config = config;
286+ self . config = Arc :: new ( config) ;
286287
287288 Ok ( ( ) )
288289 }
289290
290291 #[ cfg( feature = "unstable-config" ) ]
291292 /// Get the current configuration.
292293 fn config ( & self ) -> & Config {
293- & self . config
294+ & * self . config
294295 }
295296}
296297
@@ -304,7 +305,7 @@ impl TryFrom<Config> for H1Client {
304305 #[ cfg( any( feature = "native-tls" , feature = "rustls" ) ) ]
305306 https_pools : DashMap :: new ( ) ,
306307 max_concurrent_connections : DEFAULT_MAX_CONCURRENT_CONNECTIONS ,
307- config,
308+ config : Arc :: new ( config ) ,
308309 } )
309310 }
310311}
0 commit comments