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
commita5b2814770f4c1a564d73b3a30ca40b86f99711a (patch)
tree776eb2919d6c8dcd4bd432fcef2cadc32960aaaa /Library
parentd9f327083bba063450be8f8aa44e2e7a27c1b5d4 (diff)
downloadbrew-a5b2814770f4c1a564d73b3a30ca40b86f99711a.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 Homebrew/homebrew#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}"