Skip to content

Commit f8b679a

Browse files
committed
Add test with a chunk just under the buffer size (currently fails)
Attempting to decode a chunk with length 0xFF7 (4087), exactly 9 bytes less than the buffer size, causes the decoder to stop after that chunk.
1 parent b19548e commit f8b679a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/chunked/decoder.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,4 +593,26 @@ mod tests {
593593
assert_eq!(trailers["Expires"], "Wed, 21 Oct 2015 07:28:00 GMT");
594594
});
595595
}
596+
597+
#[test]
598+
fn test_ff7() {
599+
async_std::task::block_on(async move {
600+
let mut input: Vec<u8> = b"FF7\r\n".to_vec();
601+
input.extend(vec![b'X'; 0xFF7]);
602+
input.extend(b"\r\n4\r\n");
603+
input.extend(vec![b'Y'; 4]);
604+
input.extend(b"\r\n0\r\n\r\n");
605+
606+
let (s, _r) = async_channel::bounded(1);
607+
let sender = Sender::new(s);
608+
let mut decoder = ChunkedDecoder::new(async_std::io::Cursor::new(input), sender);
609+
610+
let mut output = String::new();
611+
decoder.read_to_string(&mut output).await.unwrap();
612+
assert_eq!(
613+
output,
614+
"X".to_string().repeat(0xFF7) + &"Y".to_string().repeat(4)
615+
);
616+
});
617+
}
596618
}

0 commit comments

Comments
 (0)