Curl: Allow option to omit --retry in curl_args

This commit is contained in:
Sam Ford 2020-12-19 17:56:25 -05:00
parent 9d92ed868b
commit e687774e8a
No known key found for this signature in database
GPG Key ID: 95209E46C7FFDEFE

View File

@ -21,7 +21,7 @@ module Utils
@curl
end
def curl_args(*extra_args, show_output: false, user_agent: :default)
def curl_args(*extra_args, **options)
args = []
# do not load .curlrc unless requested (must be the first argument)
@ -31,25 +31,25 @@ module Utils
args << "--show-error"
args << "--user-agent" << case user_agent
args << "--user-agent" << case options[:user_agent]
when :browser, :fake
HOMEBREW_USER_AGENT_FAKE_SAFARI
when :default
when :default, nil
HOMEBREW_USER_AGENT_CURL
else
user_agent
when String
options[:user_agent]
end
args << "--header" << "Accept-Language: en"
unless show_output
unless options[:show_output] == true
args << "--fail"
args << "--progress-bar" unless Context.current.verbose?
args << "--verbose" if Homebrew::EnvConfig.curl_verbose?
args << "--silent" unless $stdout.tty?
end
args << "--retry" << Homebrew::EnvConfig.curl_retries
args << "--retry" << Homebrew::EnvConfig.curl_retries unless options[:retry] == false
args + extra_args
end