Skip to content

Commit

Permalink
Don't reset the buffers for each chunk we download
Browse files Browse the repository at this point in the history
Sometimes hyper sends data that can't completely decompressed, resetting
the buffer means we're losing some data and thus breaking the body
  • Loading branch information
Eijebong committed Nov 8, 2018
1 parent 9c7efd9 commit e30440c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/net/connector.rs
Expand Up @@ -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())
Expand All @@ -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())
Expand Down

0 comments on commit e30440c

Please sign in to comment.