diff options
| author | Indrajit Raychaudhuri | 2015-07-08 23:53:20 -0500 |
|---|---|---|
| committer | Mike McQuaid | 2015-07-09 12:19:58 +0100 |
| commit | 7c890261ac500da49acd801aebe244d9d12f93e3 (patch) | |
| tree | f24e9a39d4855fcae6d114d97222bcc16ced514f /Library/Homebrew | |
| parent | 6a534f569d617e6323c736be4e1753fa6ad597a9 (diff) | |
| download | brew-7c890261ac500da49acd801aebe244d9d12f93e3.tar.bz2 | |
download_strategy: private method allowing extra curl options.
This allows some curl options to be always passed to curl, with raw
head calls (`curl -I`) (in `CurlDownloadStrategy#actual_urls`) or with
actual `curl` (in `CurlDownloadStrategy#curl`).
This also avoid the need for overriding whole `_fetch` in a few cases
and just override `_curl_opts` to append additional options instead.
Closes Homebrew/homebrew#41506.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 6ee032a71..12ee8a681 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -323,9 +323,18 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy curl @url, "-C", downloaded_size, "-o", temporary_path end + # Curl options to be always passed to curl, + # with raw head calls (`curl -I`) or with actual `fetch`. + def _curl_opts + copts = [] + copts << "--user" << meta.fetch(:user) if meta.key?(:user) + copts + end + def actual_urls urls = [] - Utils.popen_read("curl", "-I", "-L", @url).scan(/^Location: (.+)$/).map do |m| + curl_args = _curl_opts << "-I" << "-L" << @url + Utils.popen_read("curl", *curl_args).scan(/^Location: (.+)$/).map do |m| urls << URI.join(urls.last || @url, m.first.chomp).to_s end urls @@ -336,8 +345,8 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy end def curl(*args) + args.concat _curl_opts args << '--connect-timeout' << '5' unless mirrors.empty? - args << "--user" << meta.fetch(:user) if meta.key?(:user) super end end @@ -390,8 +399,8 @@ end # Download from an SSL3-only host. class CurlSSL3DownloadStrategy < CurlDownloadStrategy - def _fetch - curl @url, '-3', '-C', downloaded_size, '-o', temporary_path + def _curl_opts + super << '-3' end end |
