mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-19 07:59:05 +00:00
Use a 'BufReader' for file-based bodies.
This commit is contained in:
parent
63169599a7
commit
c36701671b
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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<Response<'r>, Status> {
|
||||
Response::build().streamed_body(self).ok()
|
||||
Response::build().streamed_body(BufReader::new(self)).ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user