From ef57ecbdb7864d924322f59a80ebd3c8c947b50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Jim=C3=A9nez=20Moreno?= Date: Thu, 15 Nov 2018 08:38:52 +0100 Subject: [PATCH] Tweak limits of file chunked read and send chunks not entire body as partial payloads --- components/net/filemanager_thread.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs index 3a639cbb741..dce6da0ed0f 100644 --- a/components/net/filemanager_thread.rs +++ b/components/net/filemanager_thread.rs @@ -817,7 +817,7 @@ pub fn fetch_file_in_chunks( { if let Some(end) = range.end { let remaining_bytes = - end as usize - range.start as usize - body.len(); + end as usize - range.start as usize - body.len() + 1; if remaining_bytes <= FILE_CHUNK_SIZE { // This is the last chunk so we set buffer // len to 0 to break the reading loop. @@ -832,8 +832,9 @@ pub fn fetch_file_in_chunks( }, buffer.len(), ); - body.extend_from_slice(&buffer[0..offset]); - let _ = done_sender.send(Data::Payload(buffer)); + let chunk = &buffer[0..offset]; + body.extend_from_slice(chunk); + let _ = done_sender.send(Data::Payload(chunk.to_vec())); } buffer_len };