From 8dafd5b2f451b132ca3114ef9dd6234e5ef055de Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Sun, 8 Nov 2026 01:56:07 +0100 Subject: [PATCH] Webserver GetFileType changed --- Changelog | 4 ++++ webserver.cc | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Changelog b/Changelog index e4eed11..829bcdb 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +2026-11-08: +- WebServerClient::GetFileType is not comparing for the file extension, but more + if it contains some words like .jpg, or .html + 2026-10-24: - tcp.cc: on hosts with disabled ipv6, we could not listen on IPV4 only diff --git a/webserver.cc b/webserver.cc index 36c7127..5cd0579 100644 --- a/webserver.cc +++ b/webserver.cc @@ -176,14 +176,14 @@ std::string WebServerClient::GetFileType (std::string fname) { std::string suffix = string_to_lower (fname.substr(pos)); - if (suffix.compare (".html") == 0) return res; - if (suffix.compare (".htm") == 0) return res; - if (suffix.compare (".js") == 0) return res; - if (suffix.compare (".json") == 0) return "application/json; charset=utf-8"; - if (suffix.compare (".svg") == 0) return "image/svg+xml"; - if (suffix.compare (".png") == 0) return "image/png"; - if (suffix.compare (".jpg") == 0) return "image/jpeg"; - if (suffix.compare (".jpeg") == 0) return "image/jpeg"; + if (suffix.find (".html") != std::string::npos) return res; + if (suffix.find (".htm") != std::string::npos) return res; + if (suffix.find (".js") != std::string::npos) return res; + if (suffix.find (".json") != std::string::npos) return "application/json; charset=utf-8"; + if (suffix.find (".svg") != std::string::npos) return "image/svg+xml"; + if (suffix.find (".png") != std::string::npos) return "image/png"; + if (suffix.find (".jpg") != std::string::npos) return "image/jpeg"; + if (suffix.find (".jpeg") != std::string::npos) return "image/jpeg"; return res; };