@@ -157,6 +157,15 @@ where
157157
158158 let mut config = Self :: default ( ) ;
159159
160+ let parse_duration = |v : & str | -> Result < Duration , Self :: Rejection > {
161+ v. parse :: < u64 > ( ) . map ( Duration :: from_millis) . map_err ( |_| {
162+ (
163+ StatusCode :: BAD_REQUEST ,
164+ "Invalid duration value in C0-Config header" ,
165+ )
166+ } )
167+ } ;
168+
160169 for pair in header_str. split_whitespace ( ) {
161170 let Some ( ( key, value) ) = pair. split_once ( '=' ) else {
162171 return Err ( (
@@ -165,15 +174,6 @@ where
165174 ) ) ;
166175 } ;
167176
168- let parse_duration = |v : & str | -> Result < Duration , Self :: Rejection > {
169- v. parse :: < u64 > ( ) . map ( Duration :: from_millis) . map_err ( |_| {
170- (
171- StatusCode :: BAD_REQUEST ,
172- "Invalid duration value in C0-Config header" ,
173- )
174- } )
175- } ;
176-
177177 match key {
178178 "ct" => config. connect_timeout = Some ( parse_duration ( value) ?) ,
179179 "rt" => config. read_timeout = Some ( parse_duration ( value) ?) ,
@@ -183,12 +183,20 @@ where
183183 config. max_attempts = Some ( value. parse ( ) . map_err ( |_| {
184184 (
185185 StatusCode :: BAD_REQUEST ,
186- "Invalid max_attempts value in C0-Config hheader " ,
186+ "Invalid value for ma in C0-Config header " ,
187187 )
188188 } ) ?) ;
189189 }
190190 "ib" => config. initial_backoff = Some ( parse_duration ( value) ?) ,
191191 "mb" => config. max_backoff = Some ( parse_duration ( value) ?) ,
192+ "fps" => {
193+ config. force_path_style = Some ( value. parse ( ) . map_err ( |_| {
194+ (
195+ StatusCode :: BAD_REQUEST ,
196+ "Invalid value for fps in C0-Config header" ,
197+ )
198+ } ) ?) ;
199+ }
192200 _ => { } // Ignore unrecognized keys
193201 }
194202 }
@@ -542,6 +550,12 @@ mod tests {
542550 assert_eq ! ( config. max_attempts, Some ( 3 ) ) ;
543551 }
544552
553+ #[ tokio:: test]
554+ async fn test_c0_config_force_path_style ( ) {
555+ let config = parse_c0_config ( "fps=true" ) . await . unwrap ( ) ;
556+ assert_eq ! ( config. force_path_style, Some ( true ) ) ;
557+ }
558+
545559 #[ tokio:: test]
546560 async fn test_c0_config_mixed_settings ( ) {
547561 let config = parse_c0_config ( "ct=1000 ma=5 ib=10 oat=1500" )
@@ -591,7 +605,17 @@ mod tests {
591605 assert ! ( result. is_err( ) ) ;
592606 assert_eq ! (
593607 result. unwrap_err( ) . 1 ,
594- "Invalid max_attempts value in C0-Config hheader"
608+ "Invalid value for ma in C0-Config header"
609+ ) ;
610+ }
611+
612+ #[ tokio:: test]
613+ async fn test_c0_config_invalid_force_path_style ( ) {
614+ let result = parse_c0_config ( "fps=1" ) . await ;
615+ assert ! ( result. is_err( ) ) ;
616+ assert_eq ! (
617+ result. unwrap_err( ) . 1 ,
618+ "Invalid value for fps in C0-Config header"
595619 ) ;
596620 }
597621
0 commit comments