mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
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.
This commit is contained in:
parent
d9f327083b
commit
a5b2814770
@ -1,4 +1,3 @@
|
|||||||
require 'open-uri'
|
|
||||||
require 'utils/json'
|
require 'utils/json'
|
||||||
require 'erb'
|
require 'erb'
|
||||||
|
|
||||||
@ -208,8 +207,26 @@ end
|
|||||||
|
|
||||||
# Detect and download from Apache Mirror
|
# Detect and download from Apache Mirror
|
||||||
class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy
|
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
|
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')
|
url = mirrors.fetch('preferred') + mirrors.fetch('path_info')
|
||||||
|
|
||||||
ohai "Best Mirror #{url}"
|
ohai "Best Mirror #{url}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user