|
|
|
@ -160,12 +160,13 @@ async fn serve_file(req: &mut Request, res: &mut Response) {
|
|
|
|
|
|
|
|
|
|
if nginxsendfile {
|
|
|
|
|
// Add the content-type header.
|
|
|
|
|
res.add_header("Content-Type", mimetype, true).unwrap();
|
|
|
|
|
res.add_header("Content-Type", mimetype, false).unwrap();
|
|
|
|
|
|
|
|
|
|
// Add the header, and we're done.
|
|
|
|
|
// X-Accel-Redirect lets nginx serve the file directly, instead of us doing all that hard work.
|
|
|
|
|
let xsend = "/files/".to_string() + &filename.to_string();
|
|
|
|
|
res.add_header("X-Accel-Redirect", xsend, true).unwrap();
|
|
|
|
|
res.render("");
|
|
|
|
|
} else {
|
|
|
|
|
// If nginx sendfile is disabled, we need to render the file directly
|
|
|
|
|
let filepath = "files/".to_string() + &filename.to_string();
|
|
|
|
|