Skip to content

Conversation

@samford
Copy link
Member

@samford samford commented Dec 17, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

This adds cookies and header parameters to Utils::Curl.curl_args and related options to the livecheck url DSL method, to allow setting these values in livecheck blocks. Like the recently-added user_agent and referer options, these are intended to align with options that the Cask url method allows (using the same name and types). [I think these are the only other options from the cask url method 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 using header) but I was looking through old brew issues and saw that we had a need for setting cookies and header values in livecheck blocks 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 using header but yaak@beta uses an alternative livecheck block 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 cookies argument to curl_args will replace the --cookie /dev/null argument. From what I've seen, using --cookie /dev/null doesn't seem to print cookies to stdout, unlike the --cookie-jar /dev/null approach that it replaced. Using --cookie with a cookies argument seems to act the same way (i.e., enabling the cookie jar but not actually printing cookies to stdout), so that may be okay. That said, I may not fully understand this behavior and the goals of the existing --cookie code, so do let me know if this isn't an appropriate way to handle this.

I tested this by running brew audit --strict --online on the casks that use cookies and didn't see any issues. To be clear, CurlDownloadStrategy has its own cookie-handling logic that's used for downloading the file but the curl_args logic seems to be exercised when running other audits on the cask url (i.e., if you remove all of the --cookie code from curl_args, an audit will visibly fail when testing a related cask like crushftp). Besides that, I also manually tested the options in livecheck blocks to make sure that the curl arguments worked as expected.

This adds a `header` parameter to `Utils::Curl.curl_args`, allowing
us to set headers to use in a curl request. Like the Cask `url` DSL
`header` option, this accepts a string or array of strings.
This adds a `header` `url` option for `livecheck` blocks, so we can
specify headers to be used by curl. Similar to the other curl-related
options, this value is passed to livecheck's `page_headers` and
`page_content` methods, which passes it to a related `Utils::Curl`
method, and the value is eventually used as a `curl_args` argument.

This brings livecheck requests more in line with cask requests, where
a `header` option can be provided to the main cask `url` (as a string
or array of strings). There aren't any casks that use a `header`
argument but we had a need to set headers in a `livecheck` block
request years ago, so there's something to be said for making this
available.
This adds a `cookies` parameter to `Utils::Curl.curl_args`, allowing
us to set cookies to use in a curl request. The existing `File::NULL`
approach doesn't seem to echo cookies to `stdout` like the prior
`--cookie-jar` approach, so the behavior when using a `cookies`
argument seems similar (in terms of the lack of output).
This adds a `cookies` `url` option for `livecheck` blocks, so we can
specify cookies to be used by curl. Similar to the other curl-related
options, this value is passed to livecheck's `page_headers` and
`page_content` methods, which passes it to a related `Utils::Curl`
method, and the value is eventually used as a `curl_args` argument.

This brings livecheck requests more in line with cask requests, where
a `cookies` option can be provided to the main cask `url`. There are
only six casks that use a `cookies` argument but we had a need to set
cookies in a `livecheck` block request years ago, so there's something
to be said for making this available.
Copilot AI review requested due to automatic review settings December 17, 2025 21:29
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks again @samford!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit 528de97 Dec 18, 2025
43 checks passed
@MikeMcQuaid MikeMcQuaid deleted the livecheck/add-cookies-and-header-options branch December 18, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants