diff options
| author | Mike McQuaid | 2016-12-30 20:42:18 +0000 |
|---|---|---|
| committer | GitHub | 2016-12-30 20:42:18 +0000 |
| commit | 9e2a8248a603bdc4c90c006dc731c4001fdef88f (patch) | |
| tree | 41139c052ef0b5490a3ad4f880aacc1b2e8654c6 /Library/Homebrew/utils | |
| parent | c29a458dc15efc92e3649155d0ed44bf982cdc15 (diff) | |
| parent | b3c6334d3cde6d653427ae29892e3a14af9c5bd9 (diff) | |
| download | brew-9e2a8248a603bdc4c90c006dc731c4001fdef88f.tar.bz2 | |
Merge pull request #1725 from MikeMcQuaid/curl-homepage-reliablity
audit: improve reliability of homepage audit.
Diffstat (limited to 'Library/Homebrew/utils')
| -rw-r--r-- | Library/Homebrew/utils/curl.rb | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 00c3a591c..eab623c40 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -1,27 +1,38 @@ require "pathname" require "open3" -def curl_args(extra_args = []) +def curl_args(options = {}) curl = Pathname.new ENV["HOMEBREW_CURL"] curl = Pathname.new "/usr/bin/curl" unless curl.exist? raise "#{curl} is not executable" unless curl.exist? && curl.executable? - flags = HOMEBREW_CURL_ARGS - flags -= ["--progress-bar"] if ARGV.verbose? + args = [ + curl.to_s, + "--remote-time", + "--location", + ] - args = [curl.to_s] + flags + extra_args - args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"] - args << "--silent" if !$stdout.tty? || ENV["TRAVIS"] + unless options[:default_user_agent] + args << "--user-agent" << HOMEBREW_USER_AGENT_CURL + end + + unless options[:show_output] + args << "--progress-bar" unless ARGV.verbose? + args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"] + args << "--fail" + args << "--silent" if !$stdout.tty? || ENV["TRAVIS"] + end + + args += options[:extra_args] if options[:extra_args] args end def curl(*args) - safe_system(*curl_args(args)) + safe_system(*curl_args(extra_args: args)) end def curl_output(*args) - curl_args = curl_args(args) - curl_args -= ["--fail", "--silent"] + curl_args = curl_args(extra_args: args, show_output: true) Open3.popen3(*curl_args) do |_, stdout, stderr, wait_thread| [stdout.read, stderr.read, wait_thread.value] end |
