diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/errors.rs | 6 | ||||
-rw-r--r-- | src/listing.rs | 28 |
2 files changed, 16 insertions, 18 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()) diff --git a/src/listing.rs b/src/listing.rs index 887fa8b..25f50fa 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -323,7 +323,7 @@ pub fn directory_listing( return Ok(ServiceResponse::new( req.clone(), HttpResponse::Forbidden() - .content_type("text/plain; charset=utf-8") + .content_type(mime::TEXT_PLAIN_UTF_8) .body("Archive creation is disabled."), )); } @@ -369,20 +369,18 @@ pub fn directory_listing( } else { Ok(ServiceResponse::new( req.clone(), - HttpResponse::Ok() - .content_type("text/html; charset=utf-8") - .body( - renderer::page( - entries, - is_root, - query_params, - breadcrumbs, - &encoded_dir, - conf, - current_user, - ) - .into_string(), - ), + HttpResponse::Ok().content_type(mime::TEXT_HTML_UTF_8).body( + renderer::page( + entries, + is_root, + query_params, + breadcrumbs, + &encoded_dir, + conf, + current_user, + ) + .into_string(), + ), )) } } |