Always load net/https before referencing related constants

I put this require inside the method body, because eager-loading
net/https is slow compared to the rest of Homebrew, and utils.rb is
loaded for each `brew` invocation.

It's probably worth breaking up global.rb a bit, to reduce the amount of
code we are loading unnecessarily, but hopefully also to make inter-file
dependencies a bit more obvious.

Fixes Homebrew/homebrew#21617.
This commit is contained in:
Jack Nagel 2013-08-02 18:18:34 -05:00
parent faf0a7204a
commit ba96851606

View File

@ -244,6 +244,8 @@ module GitHub extend self
Error = Class.new(StandardError) Error = Class.new(StandardError)
def open url, headers={}, &block def open url, headers={}, &block
require 'net/https' # for exception classes below
default_headers = {'User-Agent' => HOMEBREW_USER_AGENT} default_headers = {'User-Agent' => HOMEBREW_USER_AGENT}
default_headers['Authorization'] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN default_headers['Authorization'] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN
Kernel.open(url, default_headers.merge(headers), &block) Kernel.open(url, default_headers.merge(headers), &block)