download_strategy: move requires out of method

This can cause subtle issues when an exception is marshaled between the
build process and the main Homebrew process, as the marshaled exception
may contain URI objects even when the main Homebrew process has not
loaded the URI library.

Closes Homebrew/homebrew#17642.
This commit is contained in:
Jack Nagel 2013-02-07 12:43:22 -06:00
parent 7fbeb0df3d
commit ef6d01fc8f

View File

@ -1,3 +1,6 @@
require 'open-uri'
require 'vendor/multi_json'
class AbstractDownloadStrategy class AbstractDownloadStrategy
def initialize name, package def initialize name, package
@url = package.url @url = package.url
@ -153,9 +156,6 @@ end
# Detect and download from Apache Mirror # Detect and download from Apache Mirror
class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy
def _fetch def _fetch
require 'open-uri'
require 'vendor/multi_json'
mirrors = MultiJson.decode(open("#{@url}&asjson=1").read) mirrors = MultiJson.decode(open("#{@url}&asjson=1").read)
url = mirrors.fetch('preferred') + mirrors.fetch('path_info') url = mirrors.fetch('preferred') + mirrors.fetch('path_info')