16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/uri/http_ex.rb', line 16
def checkout
tmp = TempPath.new('checkout', pathname.basename.to_s)
begin
uri = URI.parse(ENV['http_proxy'] || '')
proxy_auth = [uri.host, uri.port, uri.user, uri.password]
Net::HTTP::Proxy(*proxy_auth).start(host) do |http|
tmp.open('w') do |out|
http.get(path) do |str|
out.print str
end
end
end
rescue Exception => ex
tmp.unlink if tmp.exist?
raise CheckoutError, "Cannot checkout #{to_s} (error: #{ex.short_pp})"
end
[tmp, nil]
end
|