mirror of
https://github.com/actix/actix-web.git
synced 2024-12-23 16:40:37 +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> {
|
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||||
if let Some(mut bytes) = self.unread.take() {
|
if let Some(mut bytes) = self.unread.take() {
|
||||||
let size = cmp::min(buf.len(), bytes.len());
|
let size = cmp::min(buf.len(), bytes.len());
|
||||||
buf[..size].copy_from_slice(&bytes[..size]);
|
buf[..size].copy_from_slice(&bytes.split_to(size));
|
||||||
if bytes.len() > size {
|
if bytes.len() > 0 {
|
||||||
bytes.split_to(size);
|
|
||||||
self.unread = Some(bytes);
|
self.unread = Some(bytes);
|
||||||
}
|
}
|
||||||
Ok(size)
|
Ok(size)
|
||||||
|
|
Loading…
Reference in a new issue