diff options
author | Jan Holesovsky <kendy@collabora.com> | 2019-03-15 17:26:22 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-03-15 17:26:22 +0100 |
commit | 2383a205c76dfcd38d2cf6dd6f2e93beac73ab7b (patch) | |
tree | ae7adf2697876e4aaadd47497942ae0591d4611c /wsd/FileServer.cpp | |
parent | Revert "wsd: allow compression gzip for html and js resources" (diff) | |
download | online-2383a205c76dfcd38d2cf6dd6f2e93beac73ab7b.tar.gz online-2383a205c76dfcd38d2cf6dd6f2e93beac73ab7b.zip |
Revert "wsd: preprocess javascript file for L10n"
This reverts commit 306b12b9bc2e0808751ea24282be792839d9ca40.
Diffstat (limited to 'wsd/FileServer.cpp')
-rw-r--r-- | wsd/FileServer.cpp | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 97509813dc..b82becbf17 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -335,10 +335,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M const std::string fileType = endPoint.substr(extPoint + 1); std::string mimeType; if (fileType == "js") - { - preprocessJS(request, socket); - return; - } + mimeType = "application/javascript"; else if (fileType == "css") mimeType = "text/css"; else if (fileType == "html") @@ -1050,37 +1047,4 @@ void FileServerRequestHandler::parse(const std::locale& locale, std::istringstre ostr << varL10n.str(); } } - -void FileServerRequestHandler::preprocessJS(const HTTPRequest& request, const std::shared_ptr<StreamSocket>& socket) -{ - std::string lang("en"); - Poco::Net::HTTPResponse response; - const Poco::URI::QueryParameters params = Poco::URI(request.getURI()).getQueryParameters(); - auto pos = std::find_if(params.begin(), params.end(), - [](const std::pair<std::string, std::string>& it) { return it.first == "lang"; }); - if (pos != params.end()) - lang = pos->second; - - response.setContentType("application/javascript"); - response.set("User-Agent", HTTP_AGENT_STRING); - response.set("Date", Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT)); - response.add("X-Content-Type-Options", "nosniff"); - - const std::string relPath = getRequestPathname(request); - LOG_DBG("Preprocessing file: " << relPath); - std::string preprocess = *getUncompressedFile(relPath); - - std::ostringstream ostr; - std::istringstream istr(preprocess); - std::locale locale(LOOLWSD::Generator(lang + ".utf8")); - - parse(locale, istr, ostr, [](const std::string&) { return false; }); - - std::ostringstream oss; - response.write(oss); - oss << ostr.str(); - socket->send(oss.str()); - - LOG_DBG("Sent file: " << relPath); -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |