diff options
Diffstat (limited to 'backends/networking')
4 files changed, 22 insertions, 22 deletions
diff --git a/backends/networking/sdl_net/handlers/resourcehandler.cpp b/backends/networking/sdl_net/handlers/resourcehandler.cpp index d6c419dd51..410665f3cc 100644 --- a/backends/networking/sdl_net/handlers/resourcehandler.cpp +++ b/backends/networking/sdl_net/handlers/resourcehandler.cpp @@ -43,7 +43,27 @@ void ResourceHandler::handle(Client &client) { if (file == nullptr) return; - LocalWebserver::setClientGetHandler(client, file, 200, LocalWebserver::determineMimeType(filename)); + LocalWebserver::setClientGetHandler(client, file, 200, determineMimeType(filename)); +} + +const char *ResourceHandler::determineMimeType(Common::String &filename) { + // text + if (filename.hasSuffix(".html")) return "text/html"; + if (filename.hasSuffix(".css")) return "text/css"; + if (filename.hasSuffix(".txt")) return "text/plain"; + if (filename.hasSuffix(".js")) return "application/javascript"; + + // images + if (filename.hasSuffix(".jpeg") || filename.hasSuffix(".jpg") || filename.hasSuffix(".jpe")) return "image/jpeg"; + if (filename.hasSuffix(".gif")) return "image/gif"; + if (filename.hasSuffix(".png")) return "image/png"; + if (filename.hasSuffix(".svg")) return "image/svg+xml"; + if (filename.hasSuffix(".tiff")) return "image/tiff"; + if (filename.hasSuffix(".ico")) return "image/vnd.microsoft.icon"; + if (filename.hasSuffix(".wbmp")) return "image/vnd.wap.wbmp"; + + if (filename.hasSuffix(".zip")) return "application/zip"; + return "application/octet-stream"; } /// public diff --git a/backends/networking/sdl_net/handlers/resourcehandler.h b/backends/networking/sdl_net/handlers/resourcehandler.h index 1b4ceec468..813b80871e 100644 --- a/backends/networking/sdl_net/handlers/resourcehandler.h +++ b/backends/networking/sdl_net/handlers/resourcehandler.h @@ -29,6 +29,7 @@ namespace Networking { class ResourceHandler: public BaseHandler { void handle(Client &client); + static const char *determineMimeType(Common::String &filename); public: ResourceHandler(); virtual ~ResourceHandler(); diff --git a/backends/networking/sdl_net/localwebserver.cpp b/backends/networking/sdl_net/localwebserver.cpp index 6da27a668f..afdee5585f 100644 --- a/backends/networking/sdl_net/localwebserver.cpp +++ b/backends/networking/sdl_net/localwebserver.cpp @@ -368,26 +368,6 @@ void LocalWebserver::setClientRedirectHandler(Client &client, Common::SeekableRe client.setHandler(handler); } -const char *LocalWebserver::determineMimeType(Common::String &filename) { - // text - if (filename.hasSuffix(".html")) return "text/html"; - if (filename.hasSuffix(".css")) return "text/css"; - if (filename.hasSuffix(".txt")) return "text/plain"; - if (filename.hasSuffix(".js")) return "application/javascript"; - - // images - if (filename.hasSuffix(".jpeg") || filename.hasSuffix(".jpg") || filename.hasSuffix(".jpe")) return "image/jpeg"; - if (filename.hasSuffix(".gif")) return "image/gif"; - if (filename.hasSuffix(".png")) return "image/png"; - if (filename.hasSuffix(".svg")) return "image/svg+xml"; - if (filename.hasSuffix(".tiff")) return "image/tiff"; - if (filename.hasSuffix(".ico")) return "image/vnd.microsoft.icon"; - if (filename.hasSuffix(".wbmp")) return "image/vnd.wap.wbmp"; - - if (filename.hasSuffix(".zip")) return "application/zip"; - return "application/octet-stream"; -} - namespace { int hexDigit(char c) { if ('0' <= c && c <= '9') return c - '0'; diff --git a/backends/networking/sdl_net/localwebserver.h b/backends/networking/sdl_net/localwebserver.h index ae9445d0ea..f65d2a9551 100644 --- a/backends/networking/sdl_net/localwebserver.h +++ b/backends/networking/sdl_net/localwebserver.h @@ -103,7 +103,6 @@ public: static void setClientGetHandler(Client &client, Common::SeekableReadStream *responseStream, long code = 200, const char *mimeType = nullptr); static void setClientRedirectHandler(Client &client, Common::String response, Common::String location, const char *mimeType = nullptr); static void setClientRedirectHandler(Client &client, Common::SeekableReadStream *responseStream, Common::String location, const char *mimeType = nullptr); - static const char *determineMimeType(Common::String &filename); static Common::String urlDecode(Common::String value); static Common::String urlEncodeQueryParameterValue(Common::String value); }; |