1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

LibWeb: Add a workaround to assign a proper mime type to QOI images

This commit is contained in:
Linus Groh 2021-12-21 01:27:38 +01:00
parent 0717e484f6
commit 67788641d3

View file

@ -79,6 +79,11 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap
if (content_type.has_value()) {
dbgln_if(RESOURCE_DEBUG, "Content-Type header: '{}'", content_type.value());
m_mime_type = mime_type_from_content_type(content_type.value());
// FIXME: "The Quite OK Image Format" doesn't have an official mime type yet,
// and servers like nginx will send a generic octet-stream mime type instead.
// Let's use image/x-qoi for now, which is also what our Core::MimeData uses & would guess.
if (m_mime_type == "application/octet-stream" && url().path().ends_with(".qoi"))
m_mime_type = "image/x-qoi";
} else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
dbgln_if(RESOURCE_DEBUG, "This is a data URL with mime-type _{}_", url().data_mime_type());
m_mime_type = url().data_mime_type();