diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-28 10:51:37 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-28 10:51:37 +0000 |
commit | c4130b0958f0a8c88011d8fc4aeb54ab1b35f3d5 (patch) | |
tree | 09565b9cb2499bfe25cba63db11ba1f421829696 /lib | |
parent | ec7c76c446fcb7fafae2fa2f7eda78c2387fac23 (diff) | |
download | ruby-c4130b0958f0a8c88011d8fc4aeb54ab1b35f3d5.tar.gz |
Net::HTTP.new: Support no_proxy parameter [Feature #11195]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net/http.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb index 9bb284a081..bfc6d4535d 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -629,10 +629,11 @@ module Net #:nodoc: # # If you are connecting to a custom proxy, +p_addr+ the DNS name or IP # address of the proxy host, +p_port+ the port to use to access the proxy, - # and +p_user+ and +p_pass+ the username and password if authorization is - # required to use the proxy. + # +p_user+ and +p_pass+ the username and password if authorization is + # required to use the proxy, and p_no_proxy spcifies hosts which doesn't + # use the proxy. # - def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil) + def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil) http = super address, port if proxy_class? then # from Net::HTTP::Proxy() @@ -644,6 +645,10 @@ module Net #:nodoc: elsif p_addr == :ENV then http.proxy_from_env = true else + if p_addr && p_no_proxy && !URI::Generic.use_proxy?(p_addr, p_addr, p_port, p_no_proxy) + p_addr = nil + p_port = nil + end http.proxy_address = p_addr http.proxy_port = p_port || default_port http.proxy_user = p_user |