From 206d63a20b60fb8f1c87e41c5ede5e34680d03ca Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 28 Jun 2019 07:07:52 +0200 Subject: [PATCH] file download: avoid unnecessary copy --- src/server/rest.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/server/rest.rs b/src/server/rest.rs index 445af4de..59237920 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -420,10 +420,7 @@ fn chuncked_static_file_download(filename: PathBuf) -> BoxFut { .map_err(|err| http_err!(BAD_REQUEST, format!("File open failed: {}", err))) .and_then(move |file| { let payload = tokio::codec::FramedRead::new(file, tokio::codec::BytesCodec::new()). - map(|bytes| { - //sigh - howto avoid copy here? or the whole map() ?? - hyper::Chunk::from(bytes.to_vec()) - }); + map(|bytes| hyper::Chunk::from(bytes.freeze())); let body = Body::wrap_stream(payload); // fixme: set other headers ?