aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils
diff options
context:
space:
mode:
authorJCount2017-08-07 17:33:12 -0400
committerGitHub2017-08-07 17:33:12 -0400
commitae1986ac910a888ceda5a0b18d14a3b3b7bcb446 (patch)
treee39a40888f007b39909711a76075ae822ab364ae /Library/Homebrew/utils
parent6ef49d8b86e436cb37df1344019189a2f2df0bbb (diff)
parent986887b413897413266151c92d5071d0a82cf966 (diff)
downloadbrew-ae1986ac910a888ceda5a0b18d14a3b3b7bcb446.tar.bz2
Merge pull request #3018 from Homebrew/revert-2848-refactoring
Revert "Refactor SVN and cURL download strategies."
Diffstat (limited to 'Library/Homebrew/utils')
-rw-r--r--Library/Homebrew/utils/curl.rb42
-rw-r--r--Library/Homebrew/utils/github.rb2
2 files changed, 20 insertions, 24 deletions
diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb
index 6aaf9be0c..5a40ae846 100644
--- a/Library/Homebrew/utils/curl.rb
+++ b/Library/Homebrew/utils/curl.rb
@@ -1,46 +1,42 @@
require "pathname"
require "open3"
-def curl_executable
+def curl_args(options = {})
curl = Pathname.new ENV["HOMEBREW_CURL"]
curl = Pathname.new "/usr/bin/curl" unless curl.exist?
- return curl if curl.executable?
- raise "#{curl} is not executable"
-end
+ raise "#{curl} is not executable" unless curl.exist? && curl.executable?
-def curl_args(*extra_args, show_output: false, user_agent: :default)
args = [
- curl_executable.to_s,
- "--fail",
- "--show-error",
+ curl.to_s,
+ "--remote-time",
+ "--location",
]
- args << "--user-agent" << case user_agent
- when :browser, :fake
- HOMEBREW_USER_AGENT_FAKE_SAFARI
- when :default
- HOMEBREW_USER_AGENT_CURL
+ case options[:user_agent]
+ when :browser
+ args << "--user-agent" << HOMEBREW_USER_AGENT_FAKE_SAFARI
else
- user_agent
+ args << "--user-agent" << HOMEBREW_USER_AGENT_CURL
end
- unless show_output
+ 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 + extra_args
+ args += options[:extra_args] if options[:extra_args]
+ args
end
def curl(*args)
- safe_system(*curl_args(*args))
-end
-
-def curl_download(*args, to: nil, **options)
- curl(*args, "--location", "--remote-time", "--continue-at", "-", "--output", to, **options)
+ safe_system(*curl_args(extra_args: args))
end
-def curl_output(*args, **options)
- Open3.capture3(*curl_args(*args, show_output: true, **options))
+def curl_output(*args)
+ 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
end
diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb
index 07eea4384..1a781cee6 100644
--- a/Library/Homebrew/utils/github.rb
+++ b/Library/Homebrew/utils/github.rb
@@ -166,7 +166,7 @@ module GitHub
args += ["--dump-header", headers_tmpfile.path]
- output, errors, status = curl_output(url.to_s, "--location", *args)
+ output, errors, status = curl_output(url.to_s, *args)
output, _, http_code = output.rpartition("\n")
output, _, http_code = output.rpartition("\n") if http_code == "000"
headers = headers_tmpfile.read