@@ -42,20 +42,14 @@ pub(super) fn content_length_parse_all_values(values: ValueIter<'_, HeaderValue>
4242 // be alright if they all contain the same value, and all parse
4343 // correctly. If not, then it's an error.
4444
45- let folded = values. fold ( None , |prev, line| match prev {
46- Some ( Ok ( prev) ) => Some (
47- line. to_str ( )
48- . map_err ( |_| ( ) )
49- . and_then ( |s| s. parse ( ) . map_err ( |_| ( ) ) )
50- . and_then ( |n| if prev == n { Ok ( n) } else { Err ( ( ) ) } ) ,
51- ) ,
52- None => Some (
53- line. to_str ( )
54- . map_err ( |_| ( ) )
55- . and_then ( |s| s. parse ( ) . map_err ( |_| ( ) ) ) ,
56- ) ,
57- Some ( Err ( ( ) ) ) => Some ( Err ( ( ) ) ) ,
58- } ) ;
45+ let folded = values. flat_map ( content_length_parse_line)
46+ . fold ( None , |prev, value| match prev {
47+ Some ( Ok ( prev) ) => Some (
48+ value. and_then ( |n| if prev == n { Ok ( n) } else { Err ( ( ) ) } ) ,
49+ ) ,
50+ None => Some ( value) ,
51+ Some ( Err ( ( ) ) ) => Some ( Err ( ( ) ) ) ,
52+ } ) ;
5953
6054 if let Some ( Ok ( n) ) = folded {
6155 Some ( n)
@@ -64,6 +58,13 @@ pub(super) fn content_length_parse_all_values(values: ValueIter<'_, HeaderValue>
6458 }
6559}
6660
61+ fn content_length_parse_line ( value : & HeaderValue ) -> Vec < Result < u64 , ( ) > > {
62+ return match value. to_str ( ) {
63+ Ok ( s) => s. split ( ',' ) . map ( |a| a. trim ( ) . parse ( ) . map_err ( |_| ( ) ) ) . collect ( ) ,
64+ Err ( _) => vec ! [ Err ( ( ) ) ] ,
65+ }
66+ }
67+
6768#[ cfg( all( feature = "http2" , feature = "client" ) ) ]
6869pub ( super ) fn method_has_defined_payload_semantics ( method : & Method ) -> bool {
6970 match * method {
0 commit comments