[MacPorts] #56975: livecheck broken in GitHub PortGroup

MacPorts noreply at macports.org
Wed Aug 15 14:38:07 UTC 2018


#56975: livecheck broken in GitHub PortGroup
---------------------+--------------------
  Reporter:  l2dy    |      Owner:  (none)
      Type:  defect  |     Status:  new
  Priority:  Normal  |  Milestone:
 Component:  ports   |    Version:
Resolution:          |   Keywords:
      Port:          |
---------------------+--------------------

Comment (by cjones051073):

 Replying to [comment:4 raimue]:
 > We cannot add the header to all requests through libcurl, as web servers
 might no longer send us some files. For example, if we want to download a
 `.tar.gz` but only accept `text/html` as content type, the server might
 reject our request.
 >
 > Probably we should have a parameter to allow passing arbitrary headers
 such as this "Accept:" into CurlFetchCmd from Tcl. Then it could only be
 used in the livecheck code.

 Yeah, I figured the same. So how about something like

 {{{
 ~/Projects/MacPorts/base > git diff
 diff --git a/src/pextlib1.0/curl.c b/src/pextlib1.0/curl.c
 index d8202bf4..d20b26c0 100644
 --- a/src/pextlib1.0/curl.c
 +++ b/src/pextlib1.0/curl.c
 @@ -178,6 +178,7 @@ CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj*
 CONST objv[])
                 };
                 char* effectiveURL = NULL;
                 char* userAgent = PACKAGE_NAME "/" PACKAGE_VERSION "
 libcurl/" LIBCURL_VERSION;
 +               char* httpHeader = "";
                 int optioncrsr;
                 int lastoption;
                 const char* theURL;
 @@ -240,6 +241,18 @@ CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj*
 CONST objv[])
                                         theResult = TCL_ERROR;
                                         break;
                                 }
 +                       } else if (strcmp(theOption, "--append-http-
 header") == 0) {
 +                               /* check we also have the parameter */
 +                               if (optioncrsr < lastoption) {
 +                                       optioncrsr++;
 +                                       httpHeader =
 Tcl_GetString(objv[optioncrsr]);
 +                               } else {
 +                                       Tcl_SetResult(interp,
 +                                               "curl fetch: --append-
 http-header option requires a parameter",
 +                                               TCL_STATIC);
 +                                       theResult = TCL_ERROR;
 +                                       break;
 +                               }
                         } else if (strcmp(theOption, "--progress") == 0) {
                                 /* check we also have the parameter */
                                 if (optioncrsr < lastoption) {
 @@ -466,6 +479,8 @@ CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj*
 CONST objv[])

                 /* Clear the Pragma: no-cache header */
                 headers = curl_slist_append(headers, "Pragma:");
 +               /* Append any optional headers */
 +               headers = curl_slist_append(headers, httpHeader);
                 theCurlCode = curl_easy_setopt(theHandle,
 CURLOPT_HTTPHEADER, headers);
                 if (theCurlCode != CURLE_OK) {
                         theResult = SetResultFromCurlErrorCode(interp,
 theCurlCode);
 diff --git a/src/port1.0/portlivecheck.tcl b/src/port1.0/portlivecheck.tcl
 index 0b88cc4c..2320d2bc 100644
 --- a/src/port1.0/portlivecheck.tcl
 +++ b/src/port1.0/portlivecheck.tcl
 @@ -75,7 +75,7 @@ proc portlivecheck::livecheck_main {args} {

      ui_debug "Port (livecheck) version is ${livecheck.version}"

 -    set curl_options {}
 +    set curl_options { "--append-http-header" "Accept: text/html" }
      if {[tbool livecheck.ignore_sslcert]} {
          lappend curl_options "--ignore-ssl-cert"
      }
 }}}

 ?

 >
 > It gets harder to find the right regex if the content is different from
 what is served to a browser, so I think we should change this in base. The
 quickfix is of course to adapt the regex.

-- 
Ticket URL: <https://trac.macports.org/ticket/56975#comment:5>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list