Hack around Zlib constant conflict
This commit is contained in:
parent
d3150f3a06
commit
e5ea0bcd65
@ -305,7 +305,7 @@ module GitHub extend self
|
|||||||
# This is a no-op if the user is opting out of using the GitHub API.
|
# This is a no-op if the user is opting out of using the GitHub API.
|
||||||
return if ENV['HOMEBREW_NO_GITHUB_API']
|
return if ENV['HOMEBREW_NO_GITHUB_API']
|
||||||
|
|
||||||
require 'net/https' # for exception classes below
|
safely_load_net_https
|
||||||
|
|
||||||
default_headers = {
|
default_headers = {
|
||||||
"User-Agent" => HOMEBREW_USER_AGENT,
|
"User-Agent" => HOMEBREW_USER_AGENT,
|
||||||
@ -402,4 +402,24 @@ module GitHub extend self
|
|||||||
uri = URI.parse("https://api.github.com/repos/#{user}/#{repo}")
|
uri = URI.parse("https://api.github.com/repos/#{user}/#{repo}")
|
||||||
open(uri) { |json| json["private"] }
|
open(uri) { |json| json["private"] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# If the zlib formula is loaded, TypeError will be raised when we try to load
|
||||||
|
# net/https. This monkeypatch prevents that and lets Net::HTTP fall back to
|
||||||
|
# the non-gzip codepath.
|
||||||
|
def safely_load_net_https
|
||||||
|
return if defined?(Net::HTTP)
|
||||||
|
if defined?(Zlib) && RUBY_VERSION >= "1.9"
|
||||||
|
require "net/protocol"
|
||||||
|
http = Class.new(Net::Protocol) do
|
||||||
|
def self.require(lib)
|
||||||
|
raise LoadError if lib == "zlib"
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Net.const_set(:HTTP, http)
|
||||||
|
end
|
||||||
|
require "net/https"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user