@@ -75,7 +75,7 @@ use tower::{
75
75
type BoxService = tower:: util:: BoxCloneService < Request < Body > , Response < Body > , crate :: BoxError > ;
76
76
type TraceInterceptor = Arc < dyn Fn ( & http:: Request < ( ) > ) -> tracing:: Span + Send + Sync + ' static > ;
77
77
78
- const DEFAULT_HTTP2_KEEPALIVE_TIMEOUT_SECS : u64 = 20 ;
78
+ const DEFAULT_HTTP2_KEEPALIVE_TIMEOUT : Duration = Duration :: from_secs ( 20 ) ;
79
79
80
80
/// A default batteries included `transport` server.
81
81
///
@@ -98,7 +98,7 @@ pub struct Server<L = Identity> {
98
98
tcp_keepalive : Option < Duration > ,
99
99
tcp_nodelay : bool ,
100
100
http2_keepalive_interval : Option < Duration > ,
101
- http2_keepalive_timeout : Option < Duration > ,
101
+ http2_keepalive_timeout : Duration ,
102
102
http2_adaptive_window : Option < bool > ,
103
103
http2_max_pending_accept_reset_streams : Option < usize > ,
104
104
http2_max_header_list_size : Option < u32 > ,
@@ -122,7 +122,7 @@ impl Default for Server<Identity> {
122
122
tcp_keepalive : None ,
123
123
tcp_nodelay : false ,
124
124
http2_keepalive_interval : None ,
125
- http2_keepalive_timeout : None ,
125
+ http2_keepalive_timeout : DEFAULT_HTTP2_KEEPALIVE_TIMEOUT ,
126
126
http2_adaptive_window : None ,
127
127
http2_max_pending_accept_reset_streams : None ,
128
128
http2_max_header_list_size : None ,
@@ -285,11 +285,11 @@ impl<L> Server<L> {
285
285
/// Default is 20 seconds.
286
286
///
287
287
#[ must_use]
288
- pub fn http2_keepalive_timeout ( self , http2_keepalive_timeout : Option < Duration > ) -> Self {
289
- Server {
290
- http2_keepalive_timeout,
291
- ..self
288
+ pub fn http2_keepalive_timeout ( mut self , http2_keepalive_timeout : Option < Duration > ) -> Self {
289
+ if let Some ( timeout) = http2_keepalive_timeout {
290
+ self . http2_keepalive_timeout = timeout;
292
291
}
292
+ self
293
293
}
294
294
295
295
/// Sets whether to use an adaptive flow control. Defaults to false.
@@ -654,9 +654,7 @@ impl<L> Server<L> {
654
654
let http2_only = !self . accept_http1 ;
655
655
656
656
let http2_keepalive_interval = self . http2_keepalive_interval ;
657
- let http2_keepalive_timeout = self
658
- . http2_keepalive_timeout
659
- . unwrap_or_else ( || Duration :: new ( DEFAULT_HTTP2_KEEPALIVE_TIMEOUT_SECS , 0 ) ) ;
657
+ let http2_keepalive_timeout = self . http2_keepalive_timeout ;
660
658
let http2_adaptive_window = self . http2_adaptive_window ;
661
659
let http2_max_pending_accept_reset_streams = self . http2_max_pending_accept_reset_streams ;
662
660
let max_connection_age = self . max_connection_age ;
0 commit comments