[前][次][番号順一覧][スレッド一覧]

ruby-changes:46684

From: naruse <ko1@a...>
Date: Sat, 20 May 2017 00:13:48 +0900 (JST)
Subject: [ruby-changes:46684] naruse:r58798 (trunk): Net::HTTP#start now pass :ENV to p_addr by default [Bug #13351]

naruse	2017-05-20 00:13:42 +0900 (Sat, 20 May 2017)

  New Revision: 58798

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58798

  Log:
    Net::HTTP#start now pass :ENV to p_addr by default [Bug #13351]
    
    To avoid this, pass nil explicitly.

  Modified files:
    trunk/NEWS
    trunk/lib/net/http.rb
    trunk/test/net/http/test_http.rb
Index: test/net/http/test_http.rb
===================================================================
--- test/net/http/test_http.rb	(revision 58797)
+++ test/net/http/test_http.rb	(revision 58798)
@@ -233,6 +233,23 @@ end https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L233
 
 module TestNetHTTP_version_1_1_methods
 
+  def test_s_start
+    h = Net::HTTP.start(config('host'), config('port'))
+    assert_equal config('host'), h.address
+    assert_equal config('port'), h.port
+    assert_equal true, h.instance_variable_get(:@proxy_from_env)
+
+    h = Net::HTTP.start(config('host'), config('port'), :ENV)
+    assert_equal config('host'), h.address
+    assert_equal config('port'), h.port
+    assert_equal true, h.instance_variable_get(:@proxy_from_env)
+
+    h = Net::HTTP.start(config('host'), config('port'), nil)
+    assert_equal config('host'), h.address
+    assert_equal config('port'), h.port
+    assert_equal false, h.instance_variable_get(:@proxy_from_env)
+  end
+
   def test_s_get
     assert_equal $test_net_http_data,
         Net::HTTP.get(config('host'), '/', config('port'))
Index: lib/net/http.rb
===================================================================
--- lib/net/http.rb	(revision 58797)
+++ lib/net/http.rb	(revision 58798)
@@ -560,7 +560,7 @@ module Net   #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L560
 
     # :call-seq:
     #   HTTP.start(address, port, p_addr, p_port, p_user, p_pass, &block)
-    #   HTTP.start(address, port=nil, p_addr=nil, p_port=nil, p_user=nil, p_pass=nil, opt, &block)
+    #   HTTP.start(address, port=nil, p_addr=:ENV, p_port=nil, p_user=nil, p_pass=nil, opt, &block)
     #
     # Creates a new Net::HTTP object, then additionally opens the TCP
     # connection and HTTP session.
@@ -591,6 +591,7 @@ module Net   #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L591
     def HTTP.start(address, *arg, &block) # :yield: +http+
       arg.pop if opt = Hash.try_convert(arg[-1])
       port, p_addr, p_port, p_user, p_pass = *arg
+      p_addr = :ENV if arg.size < 2
       port = https_default_port if !port && opt && opt[:use_ssl]
       http = new(address, port, p_addr, p_port, p_user, p_pass)
 
Index: NEWS
===================================================================
--- NEWS	(revision 58797)
+++ NEWS	(revision 58798)
@@ -86,6 +86,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L86
 
 === Compatibility issues (excluding feature bug fixes)
 
+* Net::HTTP
+  * Net::HTTP#start now pass :ENV to p_addr by default. [Bug #13351]
+    To avoid this, pass nil explicitly.
+
 * Random.raw_seed renamed to become Random.urandom.  It is now
   applicable to non-seeding purposes due to [Bug #9569].
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]