[Libreoffice-commits] online.git: Branch 'libreoffice-6-3' - wsd/LOOLWSD.cpp

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 5 09:09:16 UTC 2019


 wsd/LOOLWSD.cpp |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 6ddc1dc94fd82b573058e3b28b9e1d950864b941
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Tue Jun 4 14:45:26 2019 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Jun 5 11:08:58 2019 +0200

    Answer 404 when the file to download does not exist.
    
    This gives a better idea what has happened to those using the
    Download_As postMessage.  Without this, the attempted download just gets
    stuck.
    
    Change-Id: Ic23bbca3761d795251664cf09956468fab13ed80
    Reviewed-on: https://gerrit.libreoffice.org/73450
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>
    (cherry picked from commit 230aa62d17e4237e344fcf7d95491dbbd97ec660)
    Reviewed-on: https://gerrit.libreoffice.org/73530
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 28c91dbdf..0e0fe6098 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2542,7 +2542,6 @@ private:
                                 + JAILED_DOCUMENT_ROOT + tokens[4] + "/" + fileName);
             const std::string filePathAnonym = LOOLWSD::anonymizeUrl(filePath.toString());
             LOG_INF("HTTP request for: " << filePathAnonym);
-            bool responded = false;
             if (filePath.isAbsolute() && File(filePath).exists())
             {
                 const Poco::URI postRequestUri(request.getURI());
@@ -2567,7 +2566,6 @@ private:
                 try
                 {
                     HttpHelper::sendFile(socket, filePath.toString(), contentType, response);
-                    responded = true;
                 }
                 catch (const Exception& exc)
                 {
@@ -2580,8 +2578,15 @@ private:
             else
             {
                 LOG_ERR("Download file [" << filePathAnonym << "] not found.");
+                std::ostringstream oss;
+                oss << "HTTP/1.1 404 Not Found\r\n"
+                    << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
+                    << "User-Agent: " << HTTP_AGENT_STRING << "\r\n"
+                    << "Content-Length: 0\r\n"
+                    << "\r\n";
+                socket->send(oss.str());
+                socket->shutdown();
             }
-            (void)responded;
             return;
         }
 


More information about the Libreoffice-commits mailing list