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:
parent
82920e1ac1
commit
ec15cf2814
1 changed files with 2 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue