mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Continue decompressing chunks even after hyper is done downloading the body
If hyper reads compressed enough data, we were decompressing 32k by 32k but we were throwing away the end of the body because we would end up having lots of backed up data in the cursor when hyper was done.
This commit is contained in:
parent
e30440c9cc
commit
dcbe7d36ae
1 changed files with 31 additions and 1 deletions
|
@ -110,7 +110,37 @@ impl Stream for WrappedBody {
|
|||
},
|
||||
}
|
||||
} else {
|
||||
None
|
||||
// Hyper is done downloading but we still have uncompressed data
|
||||
match self.decoder {
|
||||
Decoder::Gzip(Some(ref mut decoder)) => {
|
||||
let mut buf = vec![0; BUF_SIZE];
|
||||
let len = decoder.read(&mut buf).ok()?;
|
||||
if len == 0 {
|
||||
return None;
|
||||
}
|
||||
buf.truncate(len);
|
||||
Some(buf.into())
|
||||
},
|
||||
Decoder::Deflate(ref mut decoder) => {
|
||||
let mut buf = vec![0; BUF_SIZE];
|
||||
let len = decoder.read(&mut buf).ok()?;
|
||||
if len == 0 {
|
||||
return None;
|
||||
}
|
||||
buf.truncate(len);
|
||||
Some(buf.into())
|
||||
},
|
||||
Decoder::Brotli(ref mut decoder) => {
|
||||
let mut buf = vec![0; BUF_SIZE];
|
||||
let len = decoder.read(&mut buf).ok()?;
|
||||
if len == 0 {
|
||||
return None;
|
||||
}
|
||||
buf.truncate(len);
|
||||
Some(buf.into())
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue