Cask::Audit: Align user agents with livecheck #17512
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 style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?The
#page_headers
and#page_content
methods inLivecheck::Strategy
will fetch a URL using our default user agent but if the request fails it will retry with the:browser
user agent. [For context, it was added as an interim measure to make URLs work that require a different user agent but I aim to remove it in the future in favor of specifying the user agent in alivecheck
block (so we don't make unnecessary requests that we know will fail).]Cask::Audit#audit_livecheck_https_availability
checks thelivecheck
block URL but it only does so using our default user agent (i.e., it calls#validate_url_for_https_availability
which callsUtils::Curl#curl_check_http_content
which has auser_agents: [:default]
parameter). Due to this behavioral mismatch, it's possible for alivecheck
block to work but for this cask audit to fail.This addresses the issue by adding
user_agents: [:default, :browser]
to the arguments the audit uses, which aligns its behavior with livecheck's.I know there's some discussion in #15350 around whether we should be switching user agents at all and I'll reply to that issue to further the discussion. In the interim time, this PR is simply about aligning existing behavior, so PRs like Homebrew/homebrew-cask#175619 will correctly pass.