Skip to content

Commit 3b22688

Browse files
committed
fix(decompression-plz): improved Init to End transition if no encodings are present
1 parent 05db1fc commit 3b22688

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

decompression-plz/src/decompression/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::decompression::{
22
dstruct::DecompressionStruct, multi::error::MultiDecompressError,
33
};
4-
use bytes::{BufMut, BytesMut, buf::Writer};
4+
use bytes::{buf::Writer, BufMut, BytesMut};
55
use header_plz::body_headers::encoding_info::EncodingInfo;
66
use tracing::error;
77

decompression-plz/src/state.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::cmp::Ordering;
22

3+
use body_plz::variants::Body;
34
use bytes::BytesMut;
45
use header_plz::body_headers::encoding_info::EncodingInfo;
56
use tracing::error;
67

78
use crate::{
8-
content_length::add_body_and_update_cl,
99
decode_struct::DecodeStruct,
1010
decompress_trait::DecompressTrait,
1111
decompression::{
@@ -26,7 +26,7 @@ pub enum DecodeState<'a, T> {
2626

2727
impl<'a, T> DecodeState<'a, T>
2828
where
29-
T: DecompressTrait + 'a,
29+
T: DecompressTrait + 'a + std::fmt::Debug,
3030
{
3131
pub fn init(message: &'a mut T, buf: &'a mut BytesMut) -> Self {
3232
let decode_struct = DecodeStruct::new(message, buf);
@@ -45,6 +45,12 @@ where
4545
} else if decode_struct.extra_body_is_some() {
4646
Self::UpdateContentLength(decode_struct)
4747
} else {
48+
if decode_struct.extra_body_is_none() {
49+
let mut body = decode_struct.take_main_body();
50+
decode_struct.message.set_body(Body::Raw(body));
51+
} else {
52+
decode_struct.add_body_and_update_cl();
53+
}
4854
Self::End
4955
};
5056
Ok(next_state)

0 commit comments

Comments
 (0)