@@ -75,8 +75,6 @@ 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 ;
79
-
80
78
/// A default batteries included `transport` server.
81
79
///
82
80
/// This provides an easy builder pattern style builder [`Server`] on top of
@@ -98,7 +96,7 @@ pub struct Server<L = Identity> {
98
96
tcp_keepalive : Option < Duration > ,
99
97
tcp_nodelay : bool ,
100
98
http2_keepalive_interval : Option < Duration > ,
101
- http2_keepalive_timeout : Option < Duration > ,
99
+ http2_keepalive_timeout : Duration ,
102
100
http2_adaptive_window : Option < bool > ,
103
101
http2_max_pending_accept_reset_streams : Option < usize > ,
104
102
http2_max_header_list_size : Option < u32 > ,
@@ -122,7 +120,7 @@ impl Default for Server<Identity> {
122
120
tcp_keepalive : None ,
123
121
tcp_nodelay : false ,
124
122
http2_keepalive_interval : None ,
125
- http2_keepalive_timeout : None ,
123
+ http2_keepalive_timeout : Duration :: from_secs ( 20 ) ,
126
124
http2_adaptive_window : None ,
127
125
http2_max_pending_accept_reset_streams : None ,
128
126
http2_max_header_list_size : None ,
@@ -285,11 +283,11 @@ impl<L> Server<L> {
285
283
/// Default is 20 seconds.
286
284
///
287
285
#[ must_use]
288
- pub fn http2_keepalive_timeout ( self , http2_keepalive_timeout : Option < Duration > ) -> Self {
289
- Server {
290
- http2_keepalive_timeout,
291
- ..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;
292
289
}
290
+ self
293
291
}
294
292
295
293
/// Sets whether to use an adaptive flow control. Defaults to false.
@@ -654,9 +652,7 @@ impl<L> Server<L> {
654
652
let http2_only = !self . accept_http1 ;
655
653
656
654
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 ) ) ;
655
+ let http2_keepalive_timeout = self . http2_keepalive_timeout ;
660
656
let http2_adaptive_window = self . http2_adaptive_window ;
661
657
let http2_max_pending_accept_reset_streams = self . http2_max_pending_accept_reset_streams ;
662
658
let max_connection_age = self . max_connection_age ;
0 commit comments