diff --git a/src/server/h2.rs b/src/server/h2.rs index d812f6f53..4c1c8a640 100644 --- a/src/server/h2.rs +++ b/src/server/h2.rs @@ -405,9 +405,8 @@ impl Read for IoWrapper { fn read(&mut self, buf: &mut [u8]) -> io::Result { 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)