mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
ec7c76c446
commit
c4130b0958
3 changed files with 22 additions and 3 deletions
4
NEWS
4
NEWS
|
@ -66,6 +66,10 @@ with all sufficient information, see the ChangeLog file or Redmine
|
||||||
|
|
||||||
* Kernel#yield_self [Feature #6721]
|
* Kernel#yield_self [Feature #6721]
|
||||||
|
|
||||||
|
* Net::HTTP
|
||||||
|
|
||||||
|
* Net::HTTP.new supports no_proxy parameter [Feature #11195]
|
||||||
|
|
||||||
* Numeric
|
* Numeric
|
||||||
|
|
||||||
* Numerical comparison operators (<,<=,>=,>) no longer rescue exceptions
|
* Numerical comparison operators (<,<=,>=,>) no longer rescue exceptions
|
||||||
|
|
|
@ -629,10 +629,11 @@ module Net #:nodoc:
|
||||||
#
|
#
|
||||||
# If you are connecting to a custom proxy, +p_addr+ the DNS name or IP
|
# 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,
|
# 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
|
# +p_user+ and +p_pass+ the username and password if authorization is
|
||||||
# required to use the proxy.
|
# 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
|
http = super address, port
|
||||||
|
|
||||||
if proxy_class? then # from Net::HTTP::Proxy()
|
if proxy_class? then # from Net::HTTP::Proxy()
|
||||||
|
@ -644,6 +645,10 @@ module Net #:nodoc:
|
||||||
elsif p_addr == :ENV then
|
elsif p_addr == :ENV then
|
||||||
http.proxy_from_env = true
|
http.proxy_from_env = true
|
||||||
else
|
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_address = p_addr
|
||||||
http.proxy_port = p_port || default_port
|
http.proxy_port = p_port || default_port
|
||||||
http.proxy_user = p_user
|
http.proxy_user = p_user
|
||||||
|
|
|
@ -97,6 +97,16 @@ class TestNetHTTP < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_proxy_address_no_proxy
|
||||||
|
clean_http_proxy_env do
|
||||||
|
http = Net::HTTP.new 'hostname.example', nil, 'proxy.example', nil, nil, nil, 'example'
|
||||||
|
assert_nil http.proxy_address
|
||||||
|
|
||||||
|
http = Net::HTTP.new '10.224.1.1', nil, 'proxy.example', nil, nil, nil, 'example,10.224.0.0/22'
|
||||||
|
assert_nil http.proxy_address
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_proxy_from_env_ENV
|
def test_proxy_from_env_ENV
|
||||||
clean_http_proxy_env do
|
clean_http_proxy_env do
|
||||||
ENV['http_proxy'] = 'http://proxy.example:8000'
|
ENV['http_proxy'] = 'http://proxy.example:8000'
|
||||||
|
|
Loading…
Reference in a new issue