@@ -282,7 +282,7 @@ where
282282 ///
283283 /// By default, the timeout is 5 seconds.
284284 pub fn timeout ( mut self , timeout : Duration ) -> Self {
285- self . config . timeout = timeout;
285+ self . config . default_connect_config . timeout = timeout;
286286 self
287287 }
288288
@@ -293,7 +293,7 @@ where
293293 ///
294294 /// By default, the timeout is 5 seconds.
295295 pub fn handshake_timeout ( mut self , timeout : Duration ) -> Self {
296- self . config . handshake_timeout = timeout;
296+ self . config . default_connect_config . handshake_timeout = timeout;
297297 self
298298 }
299299
@@ -387,7 +387,7 @@ where
387387 ///
388388 /// The default value is 65,535 and is good for APIs, but not for big objects.
389389 pub fn initial_window_size ( mut self , size : u32 ) -> Self {
390- self . config . stream_window_size = size;
390+ self . config . default_connect_config . stream_window_size = size;
391391 self
392392 }
393393
@@ -396,7 +396,7 @@ where
396396 ///
397397 /// The default value is 65,535 and is good for APIs, but not for big objects.
398398 pub fn initial_connection_window_size ( mut self , size : u32 ) -> Self {
399- self . config . conn_window_size = size;
399+ self . config . default_connect_config . conn_window_size = size;
400400 self
401401 }
402402
@@ -422,7 +422,7 @@ where
422422 /// exceeds this period, the connection is closed.
423423 /// Default keep-alive period is 15 seconds.
424424 pub fn conn_keep_alive ( mut self , dur : Duration ) -> Self {
425- self . config . conn_keep_alive = dur;
425+ self . config . default_connect_config . conn_keep_alive = dur;
426426 self
427427 }
428428
@@ -432,7 +432,7 @@ where
432432 /// until it is closed regardless of keep-alive period.
433433 /// Default lifetime period is 75 seconds.
434434 pub fn conn_lifetime ( mut self , dur : Duration ) -> Self {
435- self . config . conn_lifetime = dur;
435+ self . config . default_connect_config . conn_lifetime = dur;
436436 self
437437 }
438438
@@ -451,16 +451,16 @@ where
451451
452452 /// Set local IP Address the connector would use for establishing connection.
453453 pub fn local_address ( mut self , addr : IpAddr ) -> Self {
454- self . config . local_address = Some ( addr) ;
454+ self . config . default_connect_config . local_address = Some ( addr) ;
455455 self
456456 }
457457
458458 /// Finish configuration process and create connector service.
459459 ///
460460 /// The `Connector` builder always concludes by calling `finish()` last in its combinator chain.
461461 pub fn finish ( self ) -> ConnectorService < S , IO > {
462- let local_address = self . config . local_address ;
463- let timeout = self . config . timeout ;
462+ let local_address = self . config . default_connect_config . local_address ;
463+ let timeout = self . config . default_connect_config . timeout ;
464464
465465 let tcp_service_inner =
466466 TcpConnectorInnerService :: new ( self . connector , timeout, local_address) ;
@@ -523,7 +523,7 @@ where
523523 }
524524 }
525525
526- let handshake_timeout = self . config . handshake_timeout ;
526+ let handshake_timeout = self . config . default_connect_config . handshake_timeout ;
527527
528528 let tls_service = TlsConnectorService {
529529 tcp_service : tcp_service_inner,
@@ -557,7 +557,7 @@ where
557557 }
558558 }
559559
560- let handshake_timeout = self . config . handshake_timeout ;
560+ let handshake_timeout = self . config . default_connect_config . handshake_timeout ;
561561
562562 let tls_service = TlsConnectorService {
563563 tcp_service : tcp_service_inner,
@@ -596,7 +596,7 @@ where
596596 }
597597 }
598598
599- let handshake_timeout = self . config . handshake_timeout ;
599+ let handshake_timeout = self . config . default_connect_config . handshake_timeout ;
600600
601601 let tls_service = TlsConnectorService {
602602 tcp_service : tcp_service_inner,
@@ -630,7 +630,7 @@ where
630630 }
631631 }
632632
633- let handshake_timeout = self . config . handshake_timeout ;
633+ let handshake_timeout = self . config . default_connect_config . handshake_timeout ;
634634
635635 let tls_service = TlsConnectorService {
636636 tcp_service : tcp_service_inner,
@@ -667,7 +667,7 @@ where
667667 }
668668 }
669669
670- let handshake_timeout = self . config . handshake_timeout ;
670+ let handshake_timeout = self . config . default_connect_config . handshake_timeout ;
671671
672672 let tls_service = TlsConnectorService {
673673 tcp_service : tcp_service_inner,
@@ -701,7 +701,7 @@ where
701701 }
702702 }
703703
704- let handshake_timeout = self . config . handshake_timeout ;
704+ let handshake_timeout = self . config . default_connect_config . handshake_timeout ;
705705
706706 let tls_service = TlsConnectorService {
707707 tcp_service : tcp_service_inner,
@@ -824,9 +824,13 @@ where
824824 }
825825
826826 fn call ( & self , req : Connect ) -> Self :: Future {
827+ let timeout = req
828+ . config
829+ . clone ( )
830+ . map ( |c| c. handshake_timeout )
831+ . unwrap_or ( self . timeout ) ;
827832 let fut = self . tcp_service . call ( req) ;
828833 let tls_service = self . tls_service . clone ( ) ;
829- let timeout = self . timeout ;
830834
831835 TlsConnectorFuture :: TcpConnect {
832836 fut,
@@ -935,6 +939,7 @@ where
935939 actix_service:: forward_ready!( service) ;
936940
937941 fn call ( & self , req : Connect ) -> Self :: Future {
942+ let timeout = req. config . map ( |c| c. timeout ) . unwrap_or ( self . timeout ) ;
938943 let mut req = ConnectInfo :: new ( HostnameWithSni :: ForTcp (
939944 req. hostname ,
940945 req. port ,
@@ -949,7 +954,7 @@ where
949954
950955 TcpConnectorInnerFuture {
951956 fut : self . service . call ( req) ,
952- timeout : sleep ( self . timeout ) ,
957+ timeout : sleep ( timeout) ,
953958 }
954959 }
955960}
0 commit comments