From d9fb1c989d20c14e320eae90ec725b4000404191 Mon Sep 17 00:00:00 2001 From: Xavier Hsinyuan Date: Sun, 18 Aug 2024 18:12:11 +0800 Subject: [PATCH] Set a user-agent for curl isnewer Fix sync warning about checking update failed due to rejected connection without a user-agent on some mirrors. The user-agent for curl isnewer is conform https://trac.macports.org/ticket/40319. Closes: https://trac.macports.org/ticket/70973 --- src/pextlib1.0/curl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pextlib1.0/curl.c b/src/pextlib1.0/curl.c index d079f34e5b..82c94b4e7c 100644 --- a/src/pextlib1.0/curl.c +++ b/src/pextlib1.0/curl.c @@ -836,6 +836,7 @@ CurlIsNewerCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) CURLcode theCurlCode; long theModDate; long userModDate; + const char* userAgent = PACKAGE_NAME "/" PACKAGE_VERSION " libcurl/" LIBCURL_VERSION; optioncrsr = 2; lastoption = objc - 3; @@ -906,6 +907,13 @@ CurlIsNewerCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) break; } + /* -A option */ + theCurlCode = curl_easy_setopt(theHandle, CURLOPT_USERAGENT, userAgent); + if (theCurlCode != CURLE_OK) { + theResult = SetResultFromCurlErrorCode(interp, theCurlCode); + break; + } + /* --max-redirs option, same default as curl command line */ theCurlCode = curl_easy_setopt(theHandle, CURLOPT_MAXREDIRS, 50); if (theCurlCode != CURLE_OK) {