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)

This commit is contained in:
2025-10-26 22:25:00 +01:00
parent 146509efdf
commit f6b6b0a80b

View File

@@ -59,7 +59,14 @@ where
let val = HeaderValue::from_str(self.mime_type.as_str()).expect("Invalid MimeType"); let val = HeaderValue::from_str(self.mime_type.as_str()).expect("Invalid MimeType");
Box::pin(async move { Box::pin(async move {
let mut res = fut.await?; 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) Ok(res)
}) })
} }