aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-10-30 00:11:46 -0500
committerJack Nagel2013-10-30 00:11:46 -0500
commitce72980beb18de58c6c535b044c2fb8995d82043 (patch)
treeafcd0a333825e390ffab68ab6cef7d0f31914bea /Library
parente67dd599e9243149fe17fc9e8e1c3169e6d3101e (diff)
downloadhomebrew-ce72980beb18de58c6c535b044c2fb8995d82043.tar.bz2
Use curl to download list of Apache mirrors
Ruby's OpenURI library is somewhat broken under 1.8 and chokes on otherwise valid values of http(s)_proxy. Use curl to get the mirror list instead. Fixes #23708.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index acbb23e54..d17f39ce6 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -1,4 +1,3 @@
-require 'open-uri'
require 'utils/json'
require 'erb'
@@ -208,8 +207,26 @@ end
# Detect and download from Apache Mirror
class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy
+ def apache_mirrors
+ rd, wr = IO.pipe
+ buf = ""
+
+ pid = fork do
+ rd.close
+ $stdout.reopen(wr)
+ $stderr.reopen(wr)
+ curl "#{@url}&asjson=1"
+ end
+ wr.close
+
+ buf << rd.read until rd.eof?
+ rd.close
+ Process.wait(pid)
+ buf
+ end
+
def _fetch
- mirrors = Utils::JSON.load(open("#{@url}&asjson=1").read)
+ mirrors = Utils::JSON.load(apache_mirrors)
url = mirrors.fetch('preferred') + mirrors.fetch('path_info')
ohai "Best Mirror #{url}"