mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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:
parent
9c7efd9151
commit
e30440c9cc
1 changed files with 2 additions and 2 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue