loolwsd/FileServer.hpp | 61 +++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 29 deletions(-)
New commits: commit fe952794f0a7f04d6ae7a788e1352da00fe1159a Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Apr 16 12:26:26 2016 -0400 loolwsd: don't expose private members Change-Id: I049c92d0ddb296058fad283fffc291348b4608b1 Reviewed-on: https://gerrit.libreoffice.org/24131 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp index 6338989..293e34e 100644 --- a/loolwsd/FileServer.hpp +++ b/loolwsd/FileServer.hpp @@ -54,6 +54,7 @@ using Poco::Util::Application; class FileServerRequestHandler: public HTTPRequestHandler { public: + /// Evaluate if the cookie exists, and if not, ask for the credentials. static bool isAdminLoggedIn(HTTPServerRequest& request, HTTPServerResponse& response) { @@ -108,35 +109,6 @@ public: return false; } - void preprocessFile(HTTPServerRequest& request, HTTPServerResponse& response) - { - HTMLForm form(request, request.stream()); - - std::string preprocess; - const auto host = (LOOLWSD::SSLEnabled? "wss://": "ws://") + request.getHost(); - - Poco::URI requestUri(request.getURI()); - requestUri.normalize(); // avoid .'s and ..'s - const auto path = Poco::Path(LOOLWSD::FileServerRoot, requestUri.getPath()); - - Log::debug("Preprocessing file: " + path.toString()); - - FileInputStream file(path.toString()); - StreamCopier::copyToString(file, preprocess); - file.close(); - - Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN%"), form.get("access_token", "")); - Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN_TTL%"), form.get("access_token_ttl", "")); - Poco::replaceInPlace(preprocess, std::string("%HOST%"), host); - - response.setContentType("text/html"); - response.setContentLength(preprocess.length()); - response.setChunkedTransferEncoding(false); - - std::ostream& ostr = response.send(); - ostr << preprocess; - } - void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) override { try @@ -211,6 +183,37 @@ public: response.send(); } } + +private: + + void preprocessFile(HTTPServerRequest& request, HTTPServerResponse& response) + { + HTMLForm form(request, request.stream()); + + std::string preprocess; + const auto host = (LOOLWSD::SSLEnabled? "wss://": "ws://") + request.getHost(); + + Poco::URI requestUri(request.getURI()); + requestUri.normalize(); // avoid .'s and ..'s + const auto path = Poco::Path(LOOLWSD::FileServerRoot, requestUri.getPath()); + + Log::debug("Preprocessing file: " + path.toString()); + + FileInputStream file(path.toString()); + StreamCopier::copyToString(file, preprocess); + file.close(); + + Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN%"), form.get("access_token", "")); + Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN_TTL%"), form.get("access_token_ttl", "")); + Poco::replaceInPlace(preprocess, std::string("%HOST%"), host); + + response.setContentType("text/html"); + response.setContentLength(preprocess.length()); + response.setChunkedTransferEncoding(false); + + std::ostream& ostr = response.send(); + ostr << preprocess; + } }; class FileServer _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits