api: use Utils::Curl.curl_args

This sets user-agent nicely and avoids some duplication.
This commit is contained in:
Mike McQuaid 2023-09-02 21:31:01 -04:00
parent ec9bb2fe68
commit d5a1f3e02c
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
2 changed files with 2 additions and 6 deletions

View File

@ -48,15 +48,11 @@ module Homebrew
odie "Need to download #{url} but cannot as root! Run `brew update` without `sudo` first then try again." odie "Need to download #{url} but cannot as root! Run `brew update` without `sudo` first then try again."
end end
# TODO: consider using more of Utils::Curl curl_args = Utils::Curl.curl_args + %W[
curl_args = %W[
--compressed --compressed
--speed-limit #{ENV.fetch("HOMEBREW_CURL_SPEED_LIMIT")} --speed-limit #{ENV.fetch("HOMEBREW_CURL_SPEED_LIMIT")}
--speed-time #{ENV.fetch("HOMEBREW_CURL_SPEED_TIME")} --speed-time #{ENV.fetch("HOMEBREW_CURL_SPEED_TIME")}
] ]
curl_args << "--progress-bar" unless Context.current.verbose?
curl_args << "--verbose" if Homebrew::EnvConfig.curl_verbose?
curl_args << "--silent" if !$stdout.tty? || Context.current.quiet?
insecure_download = (ENV["HOMEBREW_SYSTEM_CA_CERTIFICATES_TOO_OLD"].present? || insecure_download = (ENV["HOMEBREW_SYSTEM_CA_CERTIFICATES_TOO_OLD"].present? ||
ENV["HOMEBREW_FORCE_BREWED_CA_CERTIFICATES"].present?) && ENV["HOMEBREW_FORCE_BREWED_CA_CERTIFICATES"].present?) &&

View File

@ -106,7 +106,7 @@ module Utils
args << "--fail" args << "--fail"
args << "--progress-bar" unless Context.current.verbose? args << "--progress-bar" unless Context.current.verbose?
args << "--verbose" if Homebrew::EnvConfig.curl_verbose? args << "--verbose" if Homebrew::EnvConfig.curl_verbose?
args << "--silent" unless $stdout.tty? args << "--silent" if !$stdout.tty? || Context.current.quiet?
end end
args << "--connect-timeout" << connect_timeout.round(3) if connect_timeout.present? args << "--connect-timeout" << connect_timeout.round(3) if connect_timeout.present?