From 67788641d3bf6bab116611c06abf300a9f85630a Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 21 Dec 2021 01:27:38 +0100 Subject: [PATCH] LibWeb: Add a workaround to assign a proper mime type to QOI images --- Userland/Libraries/LibWeb/Loader/Resource.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibWeb/Loader/Resource.cpp b/Userland/Libraries/LibWeb/Loader/Resource.cpp index 830b55c2c1..7da18ddc2c 100644 --- a/Userland/Libraries/LibWeb/Loader/Resource.cpp +++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp @@ -79,6 +79,11 @@ void Resource::did_load(Badge, 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();