From ae51e60f7007020411897a2c1ae76bf34cd17d42 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 20 Aug 2021 17:23:55 -0700 Subject: [PATCH] Set User-Agent Header --- common/kicad_curl/kicad_curl_easy.cpp | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/common/kicad_curl/kicad_curl_easy.cpp b/common/kicad_curl/kicad_curl_easy.cpp index d48063d2de..3a3dd1466c 100644 --- a/common/kicad_curl/kicad_curl_easy.cpp +++ b/common/kicad_curl/kicad_curl_easy.cpp @@ -28,8 +28,13 @@ #include #include #include -#include // THROW_IO_ERROR #include +#include + +#include +#include // THROW_IO_ERROR +#include +#include static size_t write_callback( void* contents, size_t size, size_t nmemb, void* userp ) @@ -62,6 +67,28 @@ KICAD_CURL_EASY::KICAD_CURL_EASY() : curl_easy_setopt( m_CURL, CURLOPT_WRITEFUNCTION, write_callback ); curl_easy_setopt( m_CURL, CURLOPT_WRITEDATA, (void*) &m_buffer ); + + wxPlatformInfo platformInfo; + wxString application( Pgm().App().GetAppName() ); + wxString version( GetBuildVersion() ); + wxString platform = "(" + wxGetOsDescription() + ";" + platformInfo.GetArchName(); + +#if defined( KICAD_BUILD_ARCH_X64 ) + platform << ";64-bit"; +#elif defined( KICAD_BUILD_ARCH_X86 ) + platform << ";32-bit"; +#elif defined( KICAD_BUILD_ARCH_ARM ) + platform << ";ARM 32-bit"; +#elif defined( KICAD_BUILD_ARCH_ARM64 ) + platform << ";ARM 64-bit"; +#endif + + platform << ")"; + + wxString user_agent = "KiCad/" + version + " " + platform + " " + application; + + user_agent << "/" << GetBuildDate(); + setOption( CURLOPT_USERAGENT, user_agent.ToStdString().c_str() ); }