From e4b420dfb57dec361032cf1fb1fe47cc69b46358 Mon Sep 17 00:00:00 2001 From: Christian Lohmaier Date: Tue, 28 May 2024 14:30:25 +0200 Subject: [PATCH] mar: use OS version in User-Agent this will allow the server to handle cases when we have to drop support for older versions of Windows for example Change-Id: I13f85a97179df6aa91e00853dbf6576d78854061 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168152 Reviewed-by: Christian Lohmaier Tested-by: Jenkins --- desktop/source/app/updater.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx index d60c006f6b6f..39810c2cbbdc 100644 --- a/desktop/source/app/updater.cxx +++ b/desktop/source/app/updater.cxx @@ -48,6 +48,8 @@ #include +#include + #include #include #include @@ -71,12 +73,6 @@ public: } }; -#ifdef UNX -static const char kUserAgent[] = "LibreOffice UpdateChecker/1.0 (Linux)"; -#else -static const char kUserAgent[] = "LibreOffice UpdateChecker/1.0 (unknown platform)"; -#endif - #ifdef UNX const char* const pUpdaterName = "updater"; const char* const pSofficeExeName = "soffice"; @@ -562,10 +558,14 @@ std::string download_content(const OString& rURL, bool bFile, OUString& rHash) if (!curl) return std::string(); + static const OUString kUserAgent + = u"LibreOffice UpdateChecker/1.0 (os_version)"_ustr.replaceFirst( + "os_version", Application::GetOSVersion()); + ::InitCurl_easy(curl.get()); curl_easy_setopt(curl.get(), CURLOPT_URL, rURL.getStr()); - curl_easy_setopt(curl.get(), CURLOPT_USERAGENT, kUserAgent); + curl_easy_setopt(curl.get(), CURLOPT_USERAGENT, kUserAgent.toUtf8().getStr()); bool bUseProxy = false; if (bUseProxy) {