From fcc87c901d545cb5633f1fdcbfa3b23ed0978ef2 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sat, 8 Jun 2024 10:33:48 -0400 Subject: [PATCH] Cask::Audit: Align user agents with livecheck The `#page_headers` and `#page_content` methods in `Livecheck::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 a `livecheck` block (so we don't make unnecessary requests that we know will fail).] `Cask::Audit#audit_livecheck_https_availability` checks the `livecheck` block URL but it only does so using our default user agent (i.e., it calls `#validate_url_for_https_availability` which calls `Utils::Curl#curl_check_http_content` which has a `user_agents: [:default]` parameter). Due to this behavioral mismatch, it's possible for a `livecheck` 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. --- Library/Homebrew/cask/audit.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index c6e93d3b3f..6138837dd4 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -839,7 +839,8 @@ module Cask validate_url_for_https_availability( url, "livecheck URL", - check_content: true + check_content: true, + user_agents: [:default, :browser] ) end