livecheck: add cookies and header options #21272
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
brew lgtm(style, typechecking and tests) with your changes locally?This adds
cookiesandheaderparameters toUtils::Curl.curl_argsand related options to the livecheckurlDSL method, to allow setting these values inlivecheckblocks. Like the recently-addeduser_agentandrefereroptions, these are intended to align with options that the Caskurlmethod allows (using the same name and types). [I think these are the only other options from the caskurlmethod that I wanted to add but I figured it would be good to take care of them before the next brew release.]We only have six casks using
cookies(none usingheader) but I was looking through old brew issues and saw that we had a need for setting cookies and header values inlivecheckblocks in the past (#11675), so I figured it wouldn't be a bad idea to offer these as well. We don't have any casks usingheaderbutyaak@betauses an alternativelivecheckblock approach because the preferred approach requires setting a request header, so this will allow us to implement that check.One thing to note about the implementation is that a
cookiesargument tocurl_argswill replace the--cookie /dev/nullargument. From what I've seen, using--cookie /dev/nulldoesn't seem to print cookies tostdout, unlike the--cookie-jar /dev/nullapproach that it replaced. Using--cookiewith acookiesargument seems to act the same way (i.e., enabling the cookie jar but not actually printing cookies tostdout), so that may be okay. That said, I may not fully understand this behavior and the goals of the existing--cookiecode, so do let me know if this isn't an appropriate way to handle this.I tested this by running
brew audit --strict --onlineon the casks that usecookiesand didn't see any issues. To be clear,CurlDownloadStrategyhas its own cookie-handling logic that's used for downloading the file but thecurl_argslogic seems to be exercised when running other audits on the caskurl(i.e., if you remove all of the--cookiecode fromcurl_args, an audit will visibly fail when testing a related cask likecrushftp). Besides that, I also manually tested the options inlivecheckblocks to make sure that the curl arguments worked as expected.