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

Miklos Vajna vmiklos at collabora.co.uk
Fri Oct 16 07:30:42 PDT 2015


 loolwsd/LOOLWSD.cpp |   35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

New commits:
commit 63bf9a132917d9089f3a847144d8ad6b01885777
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Oct 16 15:47:39 2015 +0200

    loolwsd: invert this condition, so it's possible to add other cases

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 3cc510c..6b13c8b 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -201,26 +201,29 @@ public:
         {
             // The user might request a file to download
             StringTokenizer tokens(request.getURI(), "/");
-            if (tokens.count() != 4)
+            if (tokens.count() == 4)
             {
-                response.setStatus(HTTPResponse::HTTP_BAD_REQUEST);
-                response.setContentLength(0);
-                response.send();
-            }
-            std::string dirPath = LOOLWSD::childRoot + "/" + tokens[1] + LOOLSession::jailDocumentURL + "/" + tokens[2];
-            std::string filePath = dirPath + "/" + tokens[3];
-            std::cout << Util::logPrefix() << "HTTP request for: " << filePath << std::endl;
-            File file(filePath);
-            if (file.exists())
-            {
-                response.set("Access-Control-Allow-Origin", "*");
-                response.sendFile(filePath, "application/octet-stream");
-                File dir(dirPath);
-                dir.remove(true);
+                std::string dirPath = LOOLWSD::childRoot + "/" + tokens[1] + LOOLSession::jailDocumentURL + "/" + tokens[2];
+                std::string filePath = dirPath + "/" + tokens[3];
+                std::cout << Util::logPrefix() << "HTTP request for: " << filePath << std::endl;
+                File file(filePath);
+                if (file.exists())
+                {
+                    response.set("Access-Control-Allow-Origin", "*");
+                    response.sendFile(filePath, "application/octet-stream");
+                    File dir(dirPath);
+                    dir.remove(true);
+                }
+                else
+                {
+                    response.setStatus(HTTPResponse::HTTP_NOT_FOUND);
+                    response.setContentLength(0);
+                    response.send();
+                }
             }
             else
             {
-                response.setStatus(HTTPResponse::HTTP_NOT_FOUND);
+                response.setStatus(HTTPResponse::HTTP_BAD_REQUEST);
                 response.setContentLength(0);
                 response.send();
             }


More information about the Libreoffice-commits mailing list