Skip to content

Commit

Permalink
Merge pull request #566 from TonnyXu/master
Browse files Browse the repository at this point in the history
Fixed the usage of passing proxy setting to open-uri module.
  • Loading branch information
kalbasit committed Feb 19, 2014
2 parents 8211ce5 + 5596bb0 commit 39c7bcb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion janus/ruby/janus/plugins.rb
Expand Up @@ -39,7 +39,13 @@ def postinstall_vim_plugin(group, name, &block)
# @param [String] path
def download_and_save_file(url, path)
proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
open_and_save_file(path, open(url, :proxy => proxy).read)

uri = URI.parse(proxy)
proxy_host = uri.scheme + "://" + uri.host + ":" + uri.port.to_s
proxy_user, proxy_pass = uri.userinfo.split(/:/) if uri.userinfo
options = { :proxy_http_basic_authentication => [proxy_host,proxy_user,proxy_pass] }

open_and_save_file(path, open(url, options).read)
end

# Open and save file
Expand Down

0 comments on commit 39c7bcb

Please sign in to comment.