diff options
-rw-r--r-- | src/get_routes.rs | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/get_routes.rs b/src/get_routes.rs index cde88c3..be2e9c4 100644 --- a/src/get_routes.rs +++ b/src/get_routes.rs @@ -340,20 +340,19 @@ fn raw_blob<C: Controller>( ctx: Context, parts: &Parts, ) -> Result<HyperResponse, Error> { - build_raw_response(entr, &ctx, parts).map(|mut resp| { - if let Some(mime) = mime_guess::from_path(&ctx.path).first() { - if mime.type_() == "text" { - // workaround for Firefox, which downloads non-plain text subtypes - // instead of displaying them (https://bugzilla.mozilla.org/1319262) - resp.headers_mut() - .insert(header::CONTENT_TYPE, "text/plain".parse().unwrap()); - } else { - resp.headers_mut() - .insert(header::CONTENT_TYPE, mime.to_string().parse().unwrap()); - } + let mut resp = build_raw_response(entr, &ctx, parts)?; + if let Some(mime) = mime_guess::from_path(&ctx.path).first() { + if mime.type_() == "text" { + // workaround for Firefox, which downloads non-plain text subtypes + // instead of displaying them (https://bugzilla.mozilla.org/1319262) + resp.headers_mut() + .insert(header::CONTENT_TYPE, "text/plain".parse().unwrap()); + } else { + resp.headers_mut() + .insert(header::CONTENT_TYPE, mime.to_string().parse().unwrap()); } - resp - }) + } + Ok(resp) } fn run_blob<C: Controller>( @@ -368,19 +367,18 @@ fn run_blob<C: Controller>( "run action only available for .html files".into(), )); } - build_raw_response(entr, &ctx, parts).map(|mut resp| { - resp.headers_mut() - .insert(header::CONTENT_TYPE, "text/html".parse().unwrap()); - // We want users to be able to view .html applications of other users - // without having to worry about the application accessing their private - // files. So we set the CSP: sandbox header which makes browsers treat - // the page as a unique origin as per the same-origin policy. - resp.headers_mut().insert( - header::CONTENT_SECURITY_POLICY, - "sandbox allow-scripts;".parse().unwrap(), - ); - resp - }) + let mut resp = build_raw_response(entr, &ctx, parts)?; + resp.headers_mut() + .insert(header::CONTENT_TYPE, "text/html".parse().unwrap()); + // We want users to be able to view .html applications of other users + // without having to worry about the application accessing their private + // files. So we set the CSP: sandbox header which makes browsers treat + // the page as a unique origin as per the same-origin policy. + resp.headers_mut().insert( + header::CONTENT_SECURITY_POLICY, + "sandbox allow-scripts;".parse().unwrap(), + ); + Ok(resp) } fn move_blob<C: Controller>( |