Merge pull request #1435 from daleglass/fix-html-mime-type

Fix mime type for serving .htm and .html files with the embedded webserver.
This commit is contained in:
Kalila 2021-11-04 19:11:05 -04:00 committed by GitHub
commit 457c622598
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -166,9 +166,10 @@ bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url,
localFileData = localFileString.toLocal8Bit();
}
// if this is an shtml file just make the MIME type match HTML so browsers aren't confused
// if this is an shtml, html or htm 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();