File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,29 +82,17 @@ pub async fn get_header<S: BuilderApiState>(
8282 }
8383
8484 // Use the minimum of the time left and the user provided timeout header
85- let max_timeout_ms = match req_headers. get ( HEADER_TIMEOUT_MS ) {
86- Some ( user_header_value) => match user_header_value. to_str ( ) {
87- Ok ( user_timeout_string) => match user_timeout_string. parse :: < u64 > ( ) {
88- Ok ( user_timeout) => {
89- if user_timeout == 0 {
90- warn ! ( "user-supplied timeout header is 0, using {max_timeout_ms}ms" ) ;
91- max_timeout_ms
92- } else {
93- user_timeout. min ( max_timeout_ms)
94- }
95- }
96- Err ( e) => {
97- warn ! ( "cannot parse user-supplied timeout header '{user_timeout_string}', using {max_timeout_ms}ms ({e})" ) ;
98- max_timeout_ms
99- }
100- } ,
101- Err ( e) => {
102- warn ! ( "invalid user-supplied timeout header, using {max_timeout_ms}ms ({e})" ) ;
85+ let max_timeout_ms = req_headers
86+ . get ( HEADER_TIMEOUT_MS )
87+ . map ( |header| match header. to_str ( ) . ok ( ) . and_then ( |v| v. parse :: < u64 > ( ) . ok ( ) ) {
88+ None | Some ( 0 ) => {
89+ // Header can't be stringified, or parsed, or it's set to 0
90+ warn ! ( ?header, "invalid user-supplied timeout header, using {max_timeout_ms}ms" ) ;
10391 max_timeout_ms
10492 }
105- } ,
106- None => max_timeout_ms ,
107- } ;
93+ Some ( user_timeout ) => user_timeout . min ( max_timeout_ms ) ,
94+ } )
95+ . unwrap_or ( max_timeout_ms ) ;
10896
10997 // prepare headers, except for start time which is set in `send_one_get_header`
11098 let mut send_headers = HeaderMap :: new ( ) ;
You can’t perform that action at this time.
0 commit comments