[Libreoffice-commits] online.git: wsd/FileServer.cpp

Pranav Kant pranavk at collabora.co.uk
Fri May 5 10:26:40 UTC 2017


 wsd/FileServer.cpp |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

New commits:
commit 052dec41bed474659d4005bf014df50283f386ec
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri May 5 14:29:55 2017 +0530

    wsd: New environment variable to not serve from memory
    
    Its quite time consuming having to restart loolwsd everytime you make
    changes in loleaflet.
    
    Change-Id: I5cc8c5af96e758309d21598c0f23fad9082130bd

diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 1aa01e11..3429ca10 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -202,22 +202,20 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M
                 }
             }
 
-            bool gzip = request.hasToken("Accept-Encoding", "gzip");
-
             response.set("User-Agent", HTTP_AGENT_STRING);
             response.set("Date", Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT));
-            if (!noCache)
-            {
-                // 60 * 60 * 24 * 128 (days) = 11059200
-                response.set("Cache-Control", "max-age=11059200");
-                response.set("ETag", "\"" LOOLWSD_VERSION_HASH "\"");
-            }
-
-            response.setContentType(mimeType);
-            response.add("X-Content-Type-Options", "nosniff");
 
+            bool gzip = request.hasToken("Accept-Encoding", "gzip");
             const std::string *content;
-            if (gzip)
+            if (std::getenv("LOOL_SERVE_FROM_FS"))
+            {
+                // Useful to not serve from memory sometimes especially during loleaflet development
+                // Avoids having to restart loolwsd everytime you make a change in loleaflet
+                const auto filePath = Poco::Path(LOOLWSD::FileServerRoot, relPath).absolute().toString();
+                HttpHelper::sendFile(socket, filePath, mimeType, response, noCache);
+                return;
+            }
+            else if (gzip)
             {
                 response.set("Content-Encoding", "gzip");
                 content = getCompressedFile(relPath);
@@ -225,6 +223,15 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M
             else
                 content = getUncompressedFile(relPath);
 
+            if (!noCache)
+            {
+                // 60 * 60 * 24 * 128 (days) = 11059200
+                response.set("Cache-Control", "max-age=11059200");
+                response.set("ETag", "\"" LOOLWSD_VERSION_HASH "\"");
+            }
+            response.setContentType(mimeType);
+            response.add("X-Content-Type-Options", "nosniff");
+
             std::ostringstream oss;
             response.write(oss);
             const std::string header = oss.str();


More information about the Libreoffice-commits mailing list