From f6b6b0a80b5e6cc62726224d0a6d99dc97fc8b53 Mon Sep 17 00:00:00 2001 From: AINDUSTRIES Date: Sun, 26 Oct 2025 22:25:00 +0100 Subject: [PATCH] Fixed issues with Content-Type headers. If one is present it should be modified without adding a new one (which would be disregarded by the browser) --- src/middleware/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/middleware/mod.rs b/src/middleware/mod.rs index bf084ad..dab2fb5 100644 --- a/src/middleware/mod.rs +++ b/src/middleware/mod.rs @@ -59,7 +59,14 @@ where let val = HeaderValue::from_str(self.mime_type.as_str()).expect("Invalid MimeType"); Box::pin(async move { let mut res = fut.await?; - res.headers_mut().append(CONTENT_TYPE, val); + match res.headers_mut().get_mut(CONTENT_TYPE) { + Some(content_type) => { + *content_type = val; + } + None => { + res.headers_mut().append(CONTENT_TYPE, val); + } + } Ok(res) }) }