[Libreoffice-commits] online.git: loolwsd/FileServer.hpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp

Jan Holesovsky kendy at collabora.com
Wed Apr 13 11:11:28 UTC 2016


 loolwsd/FileServer.hpp |    4 ++--
 loolwsd/LOOLWSD.cpp    |   13 +++++++------
 loolwsd/LOOLWSD.hpp    |    1 +
 3 files changed, 10 insertions(+), 8 deletions(-)

New commits:
commit 484335321ff3145b45ac4f2fc162be31eeffcf62
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Apr 13 13:08:47 2016 +0200

    Introduce LOOLWSD::SSLEnabled for runtime, and allow non-SSL access via WOPI.

diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp
index 721768d..06be9ec 100644
--- a/loolwsd/FileServer.hpp
+++ b/loolwsd/FileServer.hpp
@@ -111,11 +111,11 @@ public:
 
     void preprocessFile(HTTPServerRequest& request, HTTPServerResponse& response)
     {
-        Poco::URI requestUri("https", request.getHost(), request.getURI());
+        Poco::URI requestUri((LOOLWSD::SSLEnabled? "https": "http"), request.getHost(), request.getURI());
         HTMLForm form(request, request.stream());
 
         std::string preprocess;
-        const auto host = "wss://" + requestUri.getHost() + ":" + std::to_string(requestUri.getPort());
+        const auto host = (LOOLWSD::SSLEnabled? "wss://": "ws://") + requestUri.getHost() + ":" + std::to_string(requestUri.getPort());
         const auto path = Poco::Path(LOOLWSD::FileServerRoot, requestUri.getPath());
         const auto wopi = form.has("WOPISrc") ?
                           form.get("WOPISrc") + "?access_token=" + form.get("access_token","") : "";
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index a0fc215..6d68747 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -643,17 +643,12 @@ private:
     {
         DOMParser parser;
         DOMWriter writer;
-        URI uri("http", request.getHost(), request.getURI());
 
         const std::string discoveryPath = Path(Application::instance().commandPath()).parent().toString() + "discovery.xml";
         const std::string mediaType = "text/xml";
         const std::string action = "action";
         const std::string urlsrc = "urlsrc";
-#ifdef ENABLE_SSL
-        const std::string uriValue = "https://" + uri.getHost() + ":" + std::to_string(uri.getPort()) + "/loleaflet/dist/loleaflet.html?";
-#else
-        const std::string uriValue = "http://" + uri.getHost() + ":" + std::to_string(uri.getPort()) + "/loleaflet/dist/loleaflet.html?";
-#endif
+        const std::string uriValue = (LOOLWSD::SSLEnabled? "https://": "http://") + request.getHost() + "/loleaflet/dist/loleaflet.html?";
 
         InputSource inputSrc(discoveryPath);
         AutoPtr<Poco::XML::Document> docXML = parser.parse(&inputSrc);
@@ -993,6 +988,12 @@ std::string LOOLWSD::LoSubPath = "lo";
 std::string LOOLWSD::FileServerRoot;
 std::string LOOLWSD::AdminCreds;
 bool LOOLWSD::AllowLocalStorage = false;
+bool LOOLWSD::SSLEnabled =
+#ifdef ENABLE_SSL
+    true;
+#else
+    false;
+#endif
 static std::string UnitTestLibrary;
 
 unsigned int LOOLWSD::NumPreSpawnedChildren = 0;
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 105f115..4e1c127 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -46,6 +46,7 @@ public:
     static std::string FileServerRoot;
     static std::string AdminCreds;
     static bool AllowLocalStorage;
+    static bool SSLEnabled;
 
     static
     std::string GenSessionId()


More information about the Libreoffice-commits mailing list