@@ -18,6 +18,7 @@ pub enum DecodeState<'a, T> {
1818 TransferEncoding ( DecodeStruct < ' a , T > , Vec < EncodingInfo > ) ,
1919 ContentEncoding ( DecodeStruct < ' a , T > , Vec < EncodingInfo > ) ,
2020 UpdateContentLength ( DecodeStruct < ' a , T > ) ,
21+ UpdateContentLengthAndErr ( DecodeStruct < ' a , T > , MultiDecompressErrorReason ) ,
2122 End ,
2223}
2324
@@ -66,12 +67,11 @@ where
6667 }
6768 Ok ( ( ) ) => Self :: UpdateContentLength ( decode_struct) ,
6869 Err ( e) => {
69- // TODO: remove chunked TE
70- error ! ( "{}" , e) ;
70+ // TODO: maybe remove chunked TE
7171 if e. is_partial ( ) {
72- Self :: UpdateContentLength ( decode_struct)
72+ Self :: UpdateContentLengthAndErr ( decode_struct, e )
7373 } else {
74- Self :: End
74+ return Err ( e ) ;
7575 }
7676 }
7777 } ;
@@ -81,19 +81,27 @@ where
8181 mut decode_struct,
8282 mut encoding_infos,
8383 ) => {
84- match apply_encoding ( & mut decode_struct, & mut encoding_infos) {
85- Err ( e) if !e. is_partial ( ) => {
86- error ! ( "{}" , e) ;
87- return Ok ( Self :: End ) ;
84+ let next_state = if let Err ( e) =
85+ apply_encoding ( & mut decode_struct, & mut encoding_infos)
86+ {
87+ if e. is_partial ( ) {
88+ Self :: UpdateContentLengthAndErr ( decode_struct, e)
89+ } else {
90+ return Err ( e) ;
8891 }
89- _ => { }
90- }
91- Ok ( Self :: UpdateContentLength ( decode_struct) )
92+ } else {
93+ Self :: UpdateContentLength ( decode_struct)
94+ } ;
95+ Ok ( next_state)
9296 }
9397 DecodeState :: UpdateContentLength ( mut decode_struct) => {
9498 decode_struct. add_body_and_update_cl ( ) ;
9599 Ok ( Self :: End )
96100 }
101+ DecodeState :: UpdateContentLengthAndErr ( mut decode_struct, e) => {
102+ decode_struct. add_body_and_update_cl ( ) ;
103+ Err ( e)
104+ }
97105 DecodeState :: End => Ok ( Self :: End ) ,
98106 }
99107 }
0 commit comments