media: return application/octet-stream if no content-type was provided

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-05-30 23:33:52 -04:00
parent b1886583d9
commit 1af65e695d

View file

@ -62,13 +62,13 @@ pub fn content_disposition_type(buf: &[u8], content_type: &Option<String>) -> &'
#[must_use] #[must_use]
#[tracing::instrument(skip(buf))] #[tracing::instrument(skip(buf))]
pub fn make_content_type(buf: &[u8], content_type: &Option<String>) -> &'static str { pub fn make_content_type(buf: &[u8], content_type: &Option<String>) -> &'static str {
let Some(file_type) = infer::get(buf) else { let Some(claimed_content_type) = content_type else {
debug_info!("Failed to infer the file's contents");
return APPLICATION_OCTET_STREAM; return APPLICATION_OCTET_STREAM;
}; };
let Some(claimed_content_type) = content_type else { let Some(file_type) = infer::get(buf) else {
return file_type.mime_type(); debug_info!("Failed to infer the file's contents");
return APPLICATION_OCTET_STREAM;
}; };
if claimed_content_type.contains("svg") && file_type.mime_type().contains("xml") { if claimed_content_type.contains("svg") && file_type.mime_type().contains("xml") {