aboutsummaryrefslogtreecommitdiffstats
path: root/src/errors.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2022-07-24 08:46:06 +0000
committerGitHub <noreply@github.com>2022-07-24 08:46:06 +0000
commit266629fcbf87cdf3071b3d80db086fb276b75616 (patch)
treeeb5cc43063fbe8986bef7b0e83c7ef632b324868 /src/errors.rs
parentUpdate actix-web-httpauth to v0.8 (diff)
parentRemove trailing space to appease `cargo fmt` (diff)
downloadminiserve-266629fcbf87cdf3071b3d80db086fb276b75616.tar.gz
miniserve-266629fcbf87cdf3071b3d80db086fb276b75616.zip
Merge pull request #849 from cyqsimon/refactor
Minor refactoring
Diffstat (limited to 'src/errors.rs')
-rw-r--r--src/errors.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/errors.rs b/src/errors.rs
index 22351a3..b2ed459 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -103,7 +103,7 @@ impl ResponseError for ContextualError {
));
}
- resp.content_type("text/plain; charset=utf-8")
+ resp.content_type(mime::TEXT_PLAIN_UTF_8)
.body(self.to_string())
}
}
@@ -125,7 +125,7 @@ where
if (res.status().is_client_error() || res.status().is_server_error())
&& res.headers().get(header::CONTENT_TYPE).map(AsRef::as_ref)
- == Some(b"text/plain; charset=utf-8")
+ == Some(mime::TEXT_PLAIN_UTF_8.essence_str().as_bytes())
{
let req = res.request().clone();
Ok(res.map_body(|head, body| map_error_page(&req, head, body)))
@@ -155,7 +155,7 @@ fn map_error_page(req: &HttpRequest, head: &mut ResponseHead, body: BoxBody) ->
head.headers.insert(
header::CONTENT_TYPE,
- header::HeaderValue::from_static("text/html; charset=utf-8"),
+ mime::TEXT_HTML_UTF_8.essence_str().try_into().unwrap(),
);
BoxBody::new(render_error(error_msg, head.status, conf, return_address).into_string())