]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
minicurl: add parameter to set useragent
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 18 Feb 2019 09:54:30 +0000 (10:54 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 18 Feb 2019 09:54:30 +0000 (10:54 +0100)
pdns/minicurl.cc
pdns/minicurl.hh

index bd80f92cbb1f751f243342c8739942ae5e2bb237..915eeecb133d7d58553c142cdd82897ee0b01129 100644 (file)
 #include <curl/curl.h>
 #include <stdexcept>
 
-MiniCurl::MiniCurl()
+MiniCurl::MiniCurl(const string& useragent)
 {
   d_curl = curl_easy_init();
+  if (d_curl != nullptr) {
+    curl_easy_setopt(d_curl, CURLOPT_USERAGENT, useragent.c_str());
+  }
 }
 
 MiniCurl::~MiniCurl()
index 0218754f3d9873e9ea86b4d9a646e46e486ef506..7e913a897de2b16f00e5e109b6b17d0756b3bb7d 100644 (file)
@@ -31,7 +31,7 @@
 class MiniCurl
 {
 public:
-  MiniCurl();
+  MiniCurl(const string& useragent="MiniCurl/0.0");
   ~MiniCurl();
   MiniCurl& operator=(const MiniCurl&) = delete;
   std::string getURL(const std::string& str, const ComboAddress* rem=0, const ComboAddress* src=0);