@@ -73,7 +73,7 @@ use tower::{
7373type BoxService = tower:: util:: BoxCloneService < Request < Body > , Response < Body > , crate :: BoxError > ;
7474type TraceInterceptor = Arc < dyn Fn ( & http:: Request < ( ) > ) -> tracing:: Span + Send + Sync + ' static > ;
7575
76- const DEFAULT_HTTP2_KEEPALIVE_TIMEOUT_SECS : u64 = 20 ;
76+ const DEFAULT_HTTP2_KEEPALIVE_TIMEOUT : Duration = Duration :: from_secs ( 20 ) ;
7777
7878/// A default batteries included `transport` server.
7979///
@@ -96,7 +96,7 @@ pub struct Server<L = Identity> {
9696 tcp_keepalive : Option < Duration > ,
9797 tcp_nodelay : bool ,
9898 http2_keepalive_interval : Option < Duration > ,
99- http2_keepalive_timeout : Option < Duration > ,
99+ http2_keepalive_timeout : Duration ,
100100 http2_adaptive_window : Option < bool > ,
101101 http2_max_pending_accept_reset_streams : Option < usize > ,
102102 http2_max_header_list_size : Option < u32 > ,
@@ -120,7 +120,7 @@ impl Default for Server<Identity> {
120120 tcp_keepalive : None ,
121121 tcp_nodelay : false ,
122122 http2_keepalive_interval : None ,
123- http2_keepalive_timeout : None ,
123+ http2_keepalive_timeout : DEFAULT_HTTP2_KEEPALIVE_TIMEOUT ,
124124 http2_adaptive_window : None ,
125125 http2_max_pending_accept_reset_streams : None ,
126126 http2_max_header_list_size : None ,
@@ -283,11 +283,11 @@ impl<L> Server<L> {
283283 /// Default is 20 seconds.
284284 ///
285285 #[ must_use]
286- pub fn http2_keepalive_timeout ( self , http2_keepalive_timeout : Option < Duration > ) -> Self {
287- Server {
288- http2_keepalive_timeout,
289- ..self
286+ pub fn http2_keepalive_timeout ( mut self , http2_keepalive_timeout : Option < Duration > ) -> Self {
287+ if let Some ( timeout) = http2_keepalive_timeout {
288+ self . http2_keepalive_timeout = timeout;
290289 }
290+ self
291291 }
292292
293293 /// Sets whether to use an adaptive flow control. Defaults to false.
@@ -652,9 +652,7 @@ impl<L> Server<L> {
652652 let http2_only = !self . accept_http1 ;
653653
654654 let http2_keepalive_interval = self . http2_keepalive_interval ;
655- let http2_keepalive_timeout = self
656- . http2_keepalive_timeout
657- . unwrap_or_else ( || Duration :: new ( DEFAULT_HTTP2_KEEPALIVE_TIMEOUT_SECS , 0 ) ) ;
655+ let http2_keepalive_timeout = self . http2_keepalive_timeout ;
658656 let http2_adaptive_window = self . http2_adaptive_window ;
659657 let http2_max_pending_accept_reset_streams = self . http2_max_pending_accept_reset_streams ;
660658 let max_connection_age = self . max_connection_age ;
0 commit comments