diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-02-27 08:28:04 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-03-10 10:47:40 +0100 |
commit | 1bb29282f1870070fa95b70f391252c79a3e3235 (patch) | |
tree | e04d7861235b81ff0e0cdc789b6e771f58722431 /wsd/FileServer.hpp | |
parent | nb: log requests as debug and not error (diff) | |
download | online-1bb29282f1870070fa95b70f391252c79a3e3235.tar.gz online-1bb29282f1870070fa95b70f391252c79a3e3235.zip |
nb: serve files using non-blocking sockets
Change-Id: I254288980f72f197d29b7b57ec9c88a01a5a1d03
Diffstat (limited to 'wsd/FileServer.hpp')
-rw-r--r-- | wsd/FileServer.hpp | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp index a9f56cdd9f..773896859e 100644 --- a/wsd/FileServer.hpp +++ b/wsd/FileServer.hpp @@ -18,40 +18,20 @@ #include <Poco/Net/HTTPServerRequest.h> #include <Poco/Net/HTTPServerResponse.h> +#include "Socket.hpp" + /// Handles file requests over HTTP(S). -class FileServerRequestHandler : public Poco::Net::HTTPRequestHandler +class FileServerRequestHandler { - static std::string getRequestPathname(const Poco::Net::HTTPServerRequest& request); + static std::string getRequestPathname(const Poco::Net::HTTPRequest& request); - static void preprocessFile(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response) throw(Poco::FileAccessDeniedException); + static void preprocessFile(const Poco::Net::HTTPRequest& request, const std::shared_ptr<StreamSocket>& socket); public: /// Evaluate if the cookie exists, and if not, ask for the credentials. static bool isAdminLoggedIn(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response); - void handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response) override; -}; - -/// Singleton class to serve files over HTTP(S). -class FileServer -{ -public: - static FileServer& instance() - { - static FileServer fileServer; - return fileServer; - } - - static FileServerRequestHandler* createRequestHandler() - { - return new FileServerRequestHandler(); - } - - FileServer(FileServer const&) = delete; - void operator=(FileServer const&) = delete; - -private: - FileServer(); + static void handleRequest(const Poco::Net::HTTPRequest& request, const std::shared_ptr<StreamSocket>& socket); }; #endif |