Skip to content

Commit 80d8cd8

Browse files
committed
fix(decompression-plz): decode chunked logic
1 parent 1d64e1c commit 80d8cd8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

decompression-plz/src/decode_struct.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ where
2323
T: DecompressTrait + std::fmt::Debug,
2424
{
2525
pub fn new(message: &'a mut T, buf: &'a mut BytesMut) -> Self {
26-
let body = message.get_body().into_bytes().unwrap();
26+
let body = match message.get_body() {
27+
Body::Raw(data) => data,
28+
Body::Chunked(chunks) => {
29+
message.set_body(Body::Chunked(chunks));
30+
buf.split()
31+
}
32+
};
2733
let extra_body = message.get_extra_body();
2834
let body_headers = message.body_headers_as_mut().take();
2935
Self {
@@ -45,9 +51,8 @@ where
4551
}
4652

4753
pub fn chunked_to_raw(&mut self) {
48-
if let Body::Chunked(_) = self.message.get_body() {
49-
chunked_to_raw(self.message, &mut self.buf);
50-
}
54+
chunked_to_raw(self.message, &mut self.buf);
55+
self.body = self.message.get_body().into_bytes().unwrap();
5156
}
5257

5358
pub fn transfer_encoding_is_some(&self) -> bool {

0 commit comments

Comments
 (0)