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
  • Loading branch information
thelastlin authored and jmroot committed Sep 29, 2024
1 parent 70c869c commit c39ccfb
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 @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c39ccfb

Please sign in to comment.