Fix mime type for .htm and .html files

The code forces text/html for .shtml files, but if .html ones were used,
it would look up in the mime database and come up with application/x-extension-html

Web browsers try downloading that instead of rendering it.
This commit is contained in:
Dale Glass 2021-11-03 01:12:48 +01:00
parent 61367ffd47
commit 5759c76154

View file

@ -168,7 +168,8 @@ bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url,
// if this is an shtml file just make the MIME type match HTML so browsers aren't confused
// otherwise use the mimeDatabase to look it up
auto mimeType = localFileInfo.suffix() == "shtml"
auto suffix = localFileInfo.suffix();
auto mimeType = (suffix == "shtml" || suffix == "html" || suffix == "htm")
? QString { "text/html" }
: mimeDatabase.mimeTypeForFile(filePath).name();