1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-18 14:16:47 +00:00

Fixed empty buffer being sent while there's still some inside

Could occur if bytes.len() was strictly double the size of buf.len()
This commit is contained in:
Mathieu Amiot 2018-07-10 13:49:39 +02:00
parent 82920e1ac1
commit ec15cf2814

View file

@ -405,9 +405,8 @@ impl<T: Read> Read for IoWrapper<T> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
if let Some(mut bytes) = self.unread.take() {
let size = cmp::min(buf.len(), bytes.len());
buf[..size].copy_from_slice(&bytes[..size]);
if bytes.len() > size {
bytes.split_to(size);
buf[..size].copy_from_slice(&bytes.split_to(size));
if bytes.len() > 0 {
self.unread = Some(bytes);
}
Ok(size)