Replace rendering with just sending 200 OK

Fixes #22 - https://github.com/salvo-rs/salvo/issues/233
main
Volkor 1 month ago
parent 7a61fef41b
commit 9547bd8de1
Signed by: Volkor
GPG Key ID: BAD7CA8A81CC2DA5

@ -166,7 +166,8 @@ async fn serve_file(req: &mut Request, res: &mut Response) {
// 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("");
// https://github.com/salvo-rs/salvo/issues/233
res.set_status_code(StatusCode::OK);
} else {
// If nginx sendfile is disabled, we need to render the file directly
let filepath = "files/".to_string() + &filename.to_string();
@ -178,9 +179,8 @@ async fn serve_file(req: &mut Request, res: &mut Response) {
"content-type exists: content-type: {:?}",
res.headers().get("content-type").unwrap()
);
file.send(headers, res).await;
// This complains about us writing into ResBody::Stream, but it means it renders as plaintext, so who cares.
res.render("");
file.send(headers, res).await;
res.set_status_code(StatusCode::OK);
} else {
// Grab the content-type of the file
let contenttype = file.content_type().to_string();

@ -1,9 +0,0 @@
{
"Name": "cz0.au file uploader",
"DestinationType": "FileUploader",
"RequestURL": "https://cz0.au",
"FileFormName": "file",
"ResponseType": "Text",
"URL": "$json:url$",
"DeletionURL": "$json:deletionurl$"
}
Loading…
Cancel
Save