Feature #8771 ยป 378.patch
| ChangeLog | ||
|---|---|---|
| 
     Sat  11 Aug 2013 23:04:52 BST  Sam Taylor  <sjltaylor@gmail.com> 
   | 
||
| 
     	* lib/net/http.rb (Net::HTTP.start): Proxy configuration can 
   | 
||
| 
     	  can come from ENV variables. [Bug #8771] 
   | 
||
| 
     	* test/net/test_http.rb (test_override_proxy_ENV_with_start): 
   | 
||
| 
     	  that proxy configuration can come from ENV. [Bug #8771] 
   | 
||
| 
     	* test/net/test_http.rb (test_proxy_ENV_with_start): 
   | 
||
| 
     	  test ENV proxy configuration can still be overridden 
   | 
||
| 
     	  [Bug #8771] 
   | 
||
| 
     Wed Aug  7 23:06:26 2013  Akinori MUSHA  <knu@iDaemons.org> 
   | 
||
| 
     	* ruby.c (Process.argv0): New method to return the original value 
   | 
||
| lib/net/http.rb | ||
|---|---|---|
| 
           arg.pop if opt = Hash.try_convert(arg[-1]) 
   | 
||
| 
           port, p_addr, p_port, p_user, p_pass = *arg 
   | 
||
| 
           port = https_default_port if !port && opt && opt[:use_ssl] 
   | 
||
| 
           p_addr = :ENV if p_addr.nil? && arg.length < 2 
   | 
||
| 
           http = new(address, port, p_addr, p_port, p_user, p_pass) 
   | 
||
| 
           if opt 
   | 
||
| test/net/http/test_http.rb | ||
|---|---|---|
| 
     require 'test/unit' 
   | 
||
| 
     require 'net/http' 
   | 
||
| 
     require 'stringio' 
   | 
||
| 
     require 'minitest/mock' 
   | 
||
| 
     require_relative 'utils' 
   | 
||
| 
     require_relative '../../ruby/envutil' 
   | 
||
| ... | ... | |
| 
         end 
   | 
||
| 
       end 
   | 
||
| 
       def test_proxy_ENV_with_start 
   | 
||
| 
         http_mock_inst = Object.new.tap do |http| 
   | 
||
| 
           def http.start(&blk) 
   | 
||
| 
           end 
   | 
||
| 
         end 
   | 
||
| 
         captured_proxy_address = nil 
   | 
||
| 
         captured_proxy_address = lambda do |_, _, arg2, _, _, _| 
   | 
||
| 
           captured_proxy_address = arg2 
   | 
||
| 
           http_mock_inst 
   | 
||
| 
         end 
   | 
||
| 
         Net::HTTP.stub(:new, captured_proxy_address) do 
   | 
||
| 
           Net::HTTP.start('http://example') 
   | 
||
| 
         end 
   | 
||
| 
         assert_equal :ENV, captured_proxy_address 
   | 
||
| 
       end 
   | 
||
| 
       def test_override_proxy_ENV_with_start 
   | 
||
| 
         http_mock_inst = Object.new.tap do |http| 
   | 
||
| 
           def http.start(&blk) 
   | 
||
| 
           end 
   | 
||
| 
         end 
   | 
||
| 
         captured_proxy_address = nil 
   | 
||
| 
         capture_proxy_address = lambda do |_, _, arg2, _, _, _| 
   | 
||
| 
           captured_proxy_address = arg2 
   | 
||
| 
           http_mock_inst 
   | 
||
| 
         end 
   | 
||
| 
         Net::HTTP.stub(:new, capture_proxy_address) do 
   | 
||
| 
           Net::HTTP.start('http://example', 80, 'proxy_address', 'proxy_port') 
   | 
||
| 
         end 
   | 
||
| 
         assert_equal 'proxy_address', captured_proxy_address 
   | 
||
| 
       end 
   | 
||
| 
       def test_proxy_eh_no_proxy 
   | 
||
| 
         clean_http_proxy_env do 
   | 
||
| 
           assert_equal false, Net::HTTP.new('example', nil, nil).proxy? 
   | 
||