lib/geminabox/proxy/hostess.rb in geminabox-0.12.2 vs lib/geminabox/proxy/hostess.rb in geminabox-0.12.3
- old
+ new
@@ -57,16 +57,22 @@
def get_from_rubygems_if_not_local
file = File.expand_path(File.join(Server.data, *request.path_info))
unless File.exists?(file)
- ::Net::HTTP.start("production.cf.rubygems.org") do |http|
+ net_http_class.start("production.cf.rubygems.org") do |http|
path = File.join(*request.path_info)
response = http.get(path)
GemStore.create(IncomingGem.new(StringIO.new(response.body)))
end
end
+ end
+
+ def net_http_class
+ return ::Net::HTTP unless ENV['http_proxy']
+ proxy_uri = URI.parse(ENV['http_proxy'])
+ ::Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
end
def splice_file(file_name)
self.file_handler = Splicer.make(file_name)
end