livecheck/strategy: verify fail-with-body support

This commit is contained in:
Eric Knibbe 2024-05-23 13:08:25 -04:00
parent c5fba877c6
commit 07e69b0ff2
No known key found for this signature in database
GPG Key ID: 179D9CDDDB814168
2 changed files with 8 additions and 1 deletions

View File

@ -219,7 +219,7 @@ module Homebrew
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?

View File

@ -470,6 +470,13 @@ module Utils
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/")