[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/FileServer.cpp
Andras Timar
andras.timar at collabora.com
Tue May 29 12:45:02 UTC 2018
wsd/FileServer.cpp | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
New commits:
commit 3cdb93b72c827472a10998d87f4816578c10db5a
Author: Andras Timar <andras.timar at collabora.com>
Date: Fri May 18 09:48:07 2018 +0200
serve files with old gith hash in their path, that comes from cached discovery.xml
Change-Id: I157a410df0a90f9ab151b899e44566b95cbd9929
Reviewed-on: https://gerrit.libreoffice.org/54557
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 378578c56..9c9ae5489 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -33,6 +33,7 @@
#include <Poco/Net/HTTPResponse.h>
#include <Poco/Net/NameValueCollection.h>
#include <Poco/Net/NetException.h>
+#include <Poco/RegularExpression.h>
#include <Poco/Runnable.h>
#include <Poco/StreamCopier.h>
#include <Poco/StringTokenizer.h>
@@ -270,6 +271,13 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M
LOG_TRC("Fileserver request: " << requestUri.toString());
requestUri.normalize(); // avoid .'s and ..'s
+ std::string path(requestUri.getPath());
+ if (path.find("loleaflet/" LOOLWSD_VERSION_HASH "/") == std::string::npos)
+ {
+ LOG_WRN("client - server version mismatch, disabling browser cache.");
+ noCache = true;
+ }
+
std::vector<std::string> requestSegments;
requestUri.getPathSegments(requestSegments);
const std::string relPath = getRequestPathname(request);
@@ -540,9 +548,13 @@ std::string FileServerRequestHandler::getRequestPathname(const HTTPRequest& requ
requestUri.normalize();
std::string path(requestUri.getPath());
-
- // Convert version back to a real file name.
- Poco::replaceInPlace(path, std::string("/loleaflet/" LOOLWSD_VERSION_HASH "/"), std::string("/loleaflet/dist/"));
+ Poco::RegularExpression gitHashRe("/([0-9a-f]+)/");
+ std::string gitHash;
+ if (gitHashRe.extract(path, gitHash))
+ {
+ // Convert version back to a real file name.
+ Poco::replaceInPlace(path, std::string("/loleaflet" + gitHash), std::string("/loleaflet/dist/"));
+ }
return path;
}
More information about the Libreoffice-commits
mailing list