diff --git a/lib/src/response/named_file.rs b/lib/src/response/named_file.rs index 42eeba64..f41391e8 100644 --- a/lib/src/response/named_file.rs +++ b/lib/src/response/named_file.rs @@ -1,6 +1,6 @@ use std::fs::File; use std::path::{Path, PathBuf}; -use std::io; +use std::io::{self, BufReader}; use std::ops::{Deref, DerefMut}; use request::Request; @@ -90,7 +90,7 @@ impl Responder<'static> for NamedFile { } } - response.set_streamed_body(self.take_file()); + response.set_streamed_body(BufReader::new(self.take_file())); Ok(response) } } diff --git a/lib/src/response/responder.rs b/lib/src/response/responder.rs index da3c8ef1..80dfeca7 100644 --- a/lib/src/response/responder.rs +++ b/lib/src/response/responder.rs @@ -1,5 +1,5 @@ use std::fs::File; -use std::io::Cursor; +use std::io::{Cursor, BufReader}; use std::fmt; use http::{Status, ContentType}; @@ -205,7 +205,7 @@ impl<'r> Responder<'r> for String { /// Returns a response with a sized body for the file. Always returns `Ok`. impl<'r> Responder<'r> for File { fn respond_to(self, _: &Request) -> Result, Status> { - Response::build().streamed_body(self).ok() + Response::build().streamed_body(BufReader::new(self)).ok() } }