Bug #9385

open-uri always uses proxy set as env var even if proxy flag is set to nil

Added by Christophe Philemotte over 1 year ago. Updated about 1 year ago.

[ruby-core:59650]
Status:Closed
Priority:Normal
Assignee:Akira Tanaka
ruby -v:2.0.0p247 Backport:1.9.3: DONTNEED, 2.0.0: DONE, 2.1: DONE

Description

According to doc http://ruby-doc.org/stdlib-2.1.0/libdoc/open-uri/rdoc/OpenURI.html we can disable the proxy by doing

open("http://www.ruby-lang.org/en/raa.html", :proxy => nil)

and "environment variables for proxy are ignored and connection will be made to a server directly". But it is not. The environment variable is still considered and used (cf attached script and logs).

After digging the code, I think it's because Net::HTTP.new is called without passing p_addr to nil. If I'm not wrong, the attached patch is a possible solution to fix it.

run.sh Magnifier - reproducible script (109 Bytes) Christophe Philemotte, 01/09/2014 06:49 AM

logs.txt Magnifier - error output (1.3 KB) Christophe Philemotte, 01/09/2014 06:49 AM

0001-open-uri-Ignore-ENV-for-proxy-when-proxy-flag-nil.patch Magnifier - possible solution (745 Bytes) Christophe Philemotte, 01/09/2014 06:49 AM

Associated revisions

Revision 44637
Added by Akira Tanaka over 1 year ago

  • lib/open-uri.rb: Make proxy disabling working again. Fixed by Christophe Philemotte. [Bug #9385]

Revision 44637
Added by Akira Tanaka over 1 year ago

  • lib/open-uri.rb: Make proxy disabling working again. Fixed by Christophe Philemotte. [Bug #9385]

History

#1 Updated by Akira Tanaka over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r44637.


  • lib/open-uri.rb: Make proxy disabling working again. Fixed by Christophe Philemotte. [Bug #9385]

#2 Updated by Tomoyuki Chikanaga over 1 year ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED, 2.1: REQUIRED

Hi,

I've confirmed that this issue is not reproducible 1.9.3p433 with the following testcase.

This test depend on external web site because http_proxy environment variable should not affect for 127.0.0.0/8.

diff --git a/test/open-uri/test_open-uri.rb b/test/open-uri/test_open-uri.rb
index 21dd969..2a10bfd 100644
--- a/test/open-uri/test_open-uri.rb
+++ b/test/open-uri/test_open-uri.rb
@@ -234,6 +234,14 @@ class TestOpenURI < Test::Unit::TestCase
ensure
proxy.shutdown
end
+ bug9385 = ''
+ with_env("http_proxy"=>proxy_url) {
+ open("http://www.ruby-lang.org/", :proxy=>nil) {|f|
+ assert_equal("200", f.status[0], bug9385)
+ }
+ assert_equal("", log, bug9385); log.clear
+ }
}
end

#3 Updated by Tomoyuki Chikanaga about 1 year ago

  • Backport changed from 1.9.3: DONTNEED, 2.0.0: REQUIRED, 2.1: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE, 2.1: REQUIRED

r44637 was backported to ruby_2_0_0 at r45014.

#4 Updated by Yui NARUSE about 1 year ago

  • Backport changed from 1.9.3: DONTNEED, 2.0.0: DONE, 2.1: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE, 2.1: DONE

ruby_2_1 r45125 merged revision(s) 44637.

Also available in: Atom PDF