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

Pranav Kant pranavk at collabora.co.uk
Tue Dec 13 14:09:55 UTC 2016


 wsd/LOOLWSD.cpp |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 49193b3f5820bc7103b89aa24fabb1c2c69e6804
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Dec 13 19:38:05 2016 +0530

    tdf#104157: Fix Content-Type and add Content-Disposition for pdf
    
    Change-Id: I07a02a621f0f067b9810d0f92bd3b9fff112af54

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 049cd54..5bff5e6 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -715,10 +715,17 @@ private:
             LOG_INF("HTTP request for: " << filePath.toString());
             if (filePath.isAbsolute() && File(filePath).exists())
             {
+                std::string contentType = getContentType(fileName);
                 response.set("Access-Control-Allow-Origin", "*");
+                if (Poco::Path(fileName).getExtension() == "pdf")
+                {
+                    contentType = "application/pdf";
+                    response.set("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+                }
+
                 try
                 {
-                    response.sendFile(filePath.toString(), getContentType(fileName));
+                    response.sendFile(filePath.toString(), contentType);
                     responded = true;
                 }
                 catch (const Exception& exc)


More information about the Libreoffice-commits mailing list