diff options
Diffstat (limited to 'backends/networking/sdl_net/localwebserver.cpp')
-rw-r--r-- | backends/networking/sdl_net/localwebserver.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/backends/networking/sdl_net/localwebserver.cpp b/backends/networking/sdl_net/localwebserver.cpp index c8f322dad6..b2eff1667f 100644 --- a/backends/networking/sdl_net/localwebserver.cpp +++ b/backends/networking/sdl_net/localwebserver.cpp @@ -44,7 +44,7 @@ LocalWebserver::LocalWebserver(): _set(nullptr), _serverSocket(nullptr), _timerS _stopOnIdle(false), _clients(0), _idlingFrames(0) { addPathHandler("/", _indexPageHandler.getHandler()); addPathHandler("/files", _filesPageHandler.getHandler()); - addPathHandler("/create", _filesPageHandler.getHandler()); //"Create directory" feature + addPathHandler("/create", _createDirectoryHandler.getHandler()); _defaultHandler = _resourceHandler.getHandler(); } @@ -252,6 +252,21 @@ void LocalWebserver::setClientGetHandler(Client &client, Common::SeekableReadStr client.setHandler(handler); } +void LocalWebserver::setClientRedirectHandler(Client &client, Common::String response, Common::String location, const char *mimeType) { + byte *data = new byte[response.size()]; + memcpy(data, response.c_str(), response.size()); + Common::MemoryReadStream *stream = new Common::MemoryReadStream(data, response.size(), DisposeAfterUse::YES); + setClientRedirectHandler(client, stream, location, mimeType); +} + +void LocalWebserver::setClientRedirectHandler(Client &client, Common::SeekableReadStream *responseStream, Common::String location, const char *mimeType) { + GetClientHandler *handler = new GetClientHandler(responseStream); + handler->setResponseCode(302); //redirect + handler->setHeader("Location", location); + if (mimeType) handler->setHeader("Content-Type", mimeType); + client.setHandler(handler); +} + const char *LocalWebserver::determineMimeType(Common::String &filename) { // text if (filename.hasSuffix(".html")) return "text/html"; |