Skip to content

Commit 78fcf1e

Browse files
committed
feat(decompression-plz): DecodeState returns Error
1 parent 79da340 commit 78fcf1e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

decompression-plz/src/state.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ where
3030
Self::Start(decode_struct)
3131
}
3232

33-
pub fn try_next(self) -> Self {
33+
pub fn try_next(self) -> Result<Self, MultiDecompressErrorReason> {
3434
match self {
3535
DecodeState::Start(mut decode_struct) => {
36-
if decode_struct.transfer_encoding_is_some() {
36+
let next_state = if decode_struct.transfer_encoding_is_some() {
3737
let encodings = decode_struct.transfer_encoding();
3838
Self::TransferEncoding(decode_struct, encodings)
3939
} else if decode_struct.content_encoding_is_some() {
@@ -43,7 +43,8 @@ where
4343
Self::UpdateContentLength(decode_struct)
4444
} else {
4545
Self::End
46-
}
46+
};
47+
Ok(next_state)
4748
}
4849
DecodeState::TransferEncoding(
4950
mut decode_struct,
@@ -55,7 +56,10 @@ where
5556
decode_struct.chunked_to_raw();
5657
}
5758
// TODO: check if only te is chunked
58-
match apply_encoding(&mut decode_struct, &mut encoding_infos) {
59+
let next_state = match apply_encoding(
60+
&mut decode_struct,
61+
&mut encoding_infos,
62+
) {
5963
Ok(()) if decode_struct.content_encoding_is_some() => {
6064
let encodings = decode_struct.content_encoding();
6165
Self::ContentEncoding(decode_struct, encodings)
@@ -70,7 +74,8 @@ where
7074
Self::End
7175
}
7276
}
73-
}
77+
};
78+
Ok(next_state)
7479
}
7580
DecodeState::ContentEncoding(
7681
mut decode_struct,
@@ -79,17 +84,17 @@ where
7984
match apply_encoding(&mut decode_struct, &mut encoding_infos) {
8085
Err(e) if !e.is_partial() => {
8186
error!("{}", e);
82-
return Self::End;
87+
return Ok(Self::End);
8388
}
8489
_ => {}
8590
}
86-
Self::UpdateContentLength(decode_struct)
91+
Ok(Self::UpdateContentLength(decode_struct))
8792
}
8893
DecodeState::UpdateContentLength(mut decode_struct) => {
8994
decode_struct.add_body_and_update_cl();
9095
Ok(Self::End)
9196
}
92-
DecodeState::End => Self::End,
97+
DecodeState::End => Ok(Self::End),
9398
}
9499
}
95100

0 commit comments

Comments
 (0)