summaryrefslogtreecommitdiff
path: root/lingucomponent
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-03-04 19:47:42 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-03-04 17:59:56 +0000
commite35905c1b295ff4f1f03e845e8849bc8400cd952 (patch)
tree245168dcc396b73c69b53de69f0ff8e7b5db20e8 /lingucomponent
parent5a87ff41ef784d6390da0df49b60186c21047112 (diff)
Set useragent for requests to LanguageTool server
Use the same string that is used in CurlSession Change-Id: Ia383f2490cf484715f429df09ec80603ca3f9387 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148251 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'lingucomponent')
-rw-r--r--lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx
index 510539966e2e..4ad7c1388ea7 100644
--- a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx
+++ b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <config_version.h>
+
#include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
@@ -120,6 +124,15 @@ std::string makeHttpRequest_impl(std::string_view aURL, HTTP_METHOD method,
if (!curl)
return {}; // empty string
+ // Same useragent string as in CurlSession (ucp/webdav-curl/CurlSession.cxx)
+ curl_version_info_data const* const pVersion(curl_version_info(CURLVERSION_NOW));
+ assert(pVersion);
+ OString const useragent(
+ OString::Concat("LibreOffice " LIBO_VERSION_DOTTED " denylistedbackend/")
+ + ::std::string_view(pVersion->version, strlen(pVersion->version)) + " "
+ + pVersion->ssl_version);
+ (void)curl_easy_setopt(curl.get(), CURLOPT_USERAGENT, useragent.getStr());
+
(void)curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER, pHttpHeader);
(void)curl_easy_setopt(curl.get(), CURLOPT_FAILONERROR, 1L);
(void)curl_easy_setopt(curl.get(), CURLOPT_URL, aURL.data());