Jelajahi Sumber

file(DOWNLOAD): Add HTTP User-Agent string

Some servers require a User-Agent string.  The curl command-line tool
just sends "curl/$curlver", so do the same.

Suggested-by: Fredrik Ehnbom <[email protected]>
Brad King 13 tahun lalu
induk
melakukan
14aff4daf4
1 mengubah file dengan 3 tambahan dan 0 penghapusan
  1. 3 0
      Source/cmFileCommand.cxx

+ 3 - 0
Source/cmFileCommand.cxx

@@ -2857,6 +2857,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
   check_curl_result(res, "DOWNLOAD cannot set http failure option: ");
 
+  res = ::curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/" LIBCURL_VERSION);
+  check_curl_result(res, "DOWNLOAD cannot set user agent option: ");
+
   res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
                            cmWriteToFileCallback);
   check_curl_result(res, "DOWNLOAD cannot set write function: ");