From 07e69b0ff277e9dee8fd8468db6c0381c412f2a5 Mon Sep 17 00:00:00 2001 From: Eric Knibbe Date: Thu, 23 May 2024 13:08:25 -0400 Subject: [PATCH] livecheck/strategy: verify fail-with-body support --- Library/Homebrew/livecheck/strategy.rb | 2 +- Library/Homebrew/utils/curl.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/livecheck/strategy.rb b/Library/Homebrew/livecheck/strategy.rb index e3f8d8d61d412..c158207a5b645 100644 --- a/Library/Homebrew/livecheck/strategy.rb +++ b/Library/Homebrew/livecheck/strategy.rb @@ -219,7 +219,7 @@ def self.page_content(url, homebrew_curl: false) stdout, stderr, status = curl_output( *PAGE_CONTENT_CURL_ARGS, url, **DEFAULT_CURL_OPTIONS, - use_homebrew_curl: homebrew_curl, + use_homebrew_curl: homebrew_curl || !curl_supports_fail_with_body?, user_agent: ) next unless status.success? diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index d23e0270e3e8a..4b3389f6a8d01 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -470,6 +470,13 @@ def curl_http_content_headers_and_checksum( T.must(file).unlink end + def curl_supports_fail_with_body? + @curl_supports_fail_with_body ||= Hash.new do |h, key| + h[key] = Version.new(curl_output("-V").stdout[/curl (\d+(\.\d+)+)/, 1]) >= Version.new("7.76.0") + end + @curl_supports_fail_with_body[curl_path] + end + def curl_supports_tls13? @curl_supports_tls13 ||= Hash.new do |h, key| h[key] = quiet_system(curl_executable, "--tlsv1.3", "--head", "https://brew.sh/")