Skip to content

Commit c14d924

Browse files
committed
fix(decompression-plz): chunked encoding remove header
1 parent 355d060 commit c14d924

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

decompression-plz/src/state.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,20 @@ where
5252
ds.chunked_to_raw();
5353
// remove chunked TE
5454
// Chunked TE must be the last
55-
encoding_infos
56-
.last_mut()
57-
.unwrap()
58-
.encodings_as_mut()
59-
.pop();
55+
let last_info = encoding_infos.last_mut().unwrap();
56+
last_info.encodings_as_mut().pop();
57+
58+
// if after removing TE it is empty, remove the header
59+
if last_info.encodings().is_empty() {
60+
ds.message
61+
.remove_header_on_position(last_info.header_index);
62+
63+
// remove the last encoding_info
64+
encoding_infos.pop();
65+
}
6066
}
6167
// If only chunked was present then Vec<EncodingInfo> is empty
62-
let mut next_state = if is_empty_encodings(&encoding_infos) {
63-
ds.message.header_map_as_mut().remove_header_on_position(
64-
encoding_infos[0].header_index,
65-
);
68+
let mut next_state = if encoding_infos.is_empty() {
6669
if ds.content_encoding_is_some() {
6770
let encodings = ds.get_content_encoding();
6871
Self::ContentEncoding(ds, encodings)
@@ -199,8 +202,3 @@ where
199202
}
200203
}
201204
}
202-
203-
// Only chunked was present
204-
fn is_empty_encodings(einfo_vec: &[EncodingInfo]) -> bool {
205-
einfo_vec.len() == 1 && einfo_vec[0].encodings().is_empty()
206-
}

0 commit comments

Comments
 (0)