提交 d789e803 编写于 作者: S Seth Fitzsimmons 提交者: Mislav Marohnić

HTTP(S) proxy support

Determines whether an HTTP proxy has been configured and uses it if so.
上级 ebbb8591
......@@ -944,7 +944,26 @@ help
port = 80
end
http = Net::HTTP.new(url.host, port)
# sniff out proxy settings
if use_ssl
proxy = ENV['HTTPS_PROXY'] || ENV['https_proxy']
else
proxy = ENV['HTTP_PROXY'] || ENV['http_proxy']
end
if proxy
# use an HTTP(S) proxy
unless /^[^:]+:\/\// =~ proxy
proxy = "http://#{proxy}"
end
proxy = URI.parse(proxy)
http = Net::HTTP.new(url.host, port, proxy.host, proxy.port, proxy.user, proxy.password)
else
http = Net::HTTP.new(url.host, port)
end
if http.use_ssl = use_ssl
# TODO: SSL peer verification
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册