Skip to content

Commit

Permalink
Set a user-agent for curl isnewer
Browse files Browse the repository at this point in the history
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
(cherry picked from commit c39ccfb)
  • Loading branch information
thelastlin authored and jmroot committed Sep 30, 2024
1 parent 11a3f0c commit 6acee55
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pextlib1.0/curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,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;
Expand Down Expand Up @@ -905,6 +906,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) {
Expand Down

0 comments on commit 6acee55

Please sign in to comment.