From 43357493d550ffe321fffbd668a7b7a7afe6c7a9 Mon Sep 17 00:00:00 2001 From: maokwen Date: Wed, 27 Dec 2023 16:24:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix:=20explicit=20Content-Ty?= =?UTF-8?q?pe=20header=20for=20HTTP=20response=20(#457)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/router.rs | 62 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/server/router.rs b/src/server/router.rs index b9fe1d4..0fb37d1 100644 --- a/src/server/router.rs +++ b/src/server/router.rs @@ -12,14 +12,16 @@ use std::fs::read_to_string; /// Handles the route of index page or main page of the `websurfx` meta search engine website. #[get("/")] pub async fn index(config: web::Data) -> Result> { - Ok(HttpResponse::Ok().body( - crate::templates::views::index::index( - &config.style.colorscheme, - &config.style.theme, - &config.style.animation, - ) - .0, - )) + Ok(HttpResponse::Ok() + .content_type("text/html; charset=utf-8") + .body( + crate::templates::views::index::index( + &config.style.colorscheme, + &config.style.theme, + &config.style.animation, + ) + .0, + )) } /// Handles the route of any other accessed route/page which is not provided by the @@ -52,14 +54,16 @@ pub async fn robots_data(_req: HttpRequest) -> Result) -> Result> { - Ok(HttpResponse::Ok().body( - crate::templates::views::about::about( - &config.style.colorscheme, - &config.style.theme, - &config.style.animation, - ) - .0, - )) + Ok(HttpResponse::Ok() + .content_type("text/html; charset=utf-8") + .body( + crate::templates::views::about::about( + &config.style.colorscheme, + &config.style.theme, + &config.style.animation, + ) + .0, + )) } /// Handles the route of settings page of the `websurfx` meta search engine website. @@ -67,16 +71,18 @@ pub async fn about(config: web::Data) -> Result, ) -> Result> { - Ok(HttpResponse::Ok().body( - crate::templates::views::settings::settings( - &config.style.colorscheme, - &config.style.theme, - &config.style.animation, - &config - .upstream_search_engines - .keys() - .collect::>(), - )? - .0, - )) + Ok(HttpResponse::Ok() + .content_type("text/html; charset=utf-8") + .body( + crate::templates::views::settings::settings( + &config.style.colorscheme, + &config.style.theme, + &config.style.animation, + &config + .upstream_search_engines + .keys() + .collect::>(), + )? + .0, + )) } From 9f5213cf42165dd36133a2e6bcdf0e77b81edfb2 Mon Sep 17 00:00:00 2001 From: maokwen Date: Thu, 28 Dec 2023 12:05:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix:=20explicit=20`content-t?= =?UTF-8?q?ype`=20header=20for=20the=20search=20page=20response=20(#458)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/routes/search.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/server/routes/search.rs b/src/server/routes/search.rs index 84ba3de..bfd7e76 100644 --- a/src/server/routes/search.rs +++ b/src/server/routes/search.rs @@ -68,16 +68,18 @@ pub async fn search( get_results(page + 1) ); - Ok(HttpResponse::Ok().body( - crate::templates::views::search::search( - &config.style.colorscheme, - &config.style.theme, - &config.style.animation, - query, - &results?, - ) - .0, - )) + Ok(HttpResponse::Ok() + .content_type("text/html; charset=utf-8") + .body( + crate::templates::views::search::search( + &config.style.colorscheme, + &config.style.theme, + &config.style.animation, + query, + &results?, + ) + .0, + )) } None => Ok(HttpResponse::TemporaryRedirect() .insert_header(("location", "/"))