Don't reset the buffers for each chunk we download

Sometimes hyper sends data that can't completely decompressed, resetting
the buffer means we're losing some data and thus breaking the body
This commit is contained in:
Bastien Orivel 2018-11-08 02:36:59 +01:00
parent 9c7efd9151
commit e30440c9cc

View file

@ -81,7 +81,7 @@ impl Stream for WrappedBody {
Decoder::Plain => Some(chunk),
Decoder::Gzip(Some(ref mut decoder)) => {
let mut buf = vec![0; BUF_SIZE];
*decoder.get_mut() = Cursor::new(chunk.into_bytes());
decoder.get_mut().get_mut().extend(&chunk.into_bytes());
let len = decoder.read(&mut buf).ok()?;
buf.truncate(len);
Some(buf.into())
@ -96,7 +96,7 @@ impl Stream for WrappedBody {
},
Decoder::Deflate(ref mut decoder) => {
let mut buf = vec![0; BUF_SIZE];
*decoder.get_mut() = Cursor::new(chunk.into_bytes());
decoder.get_mut().get_mut().extend(&chunk.into_bytes());
let len = decoder.read(&mut buf).ok()?;
buf.truncate(len);
Some(buf.into())