ruby-changes:65935
From: Charles <ko1@a...>
Date: Thu, 22 Apr 2021 14:57:36 +0900 (JST)
Subject: [ruby-changes:65935] 6e06c980da (master): [ruby/uri] Upstream Java proxy property checks from JRuby
https://git.ruby-lang.org/ruby.git/commit/?id=6e06c980da From 6e06c980dace26ff2f06eb4ac1e2d06291101ee7 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter <headius@h...> Date: Thu, 4 Mar 2021 16:44:35 -0600 Subject: [ruby/uri] Upstream Java proxy property checks from JRuby These Java properties, retrieved from JRuby's "Java env" ENV_JAVA, allow JRuby users to use the same proxy properties the rest of the Java platform uses. This resolves https://bugs.ruby-lang.org/issues/11194 https://github.com/ruby/uri/commit/3bd2bcc95a --- lib/uri/generic.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index a4192c6..7de62b6 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1514,9 +1514,19 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1514 proxy_uri = env["CGI_#{name.upcase}"] end elsif name == 'http_proxy' - unless proxy_uri = env[name] - if proxy_uri = env[name.upcase] - warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1 + if RUBY_ENGINE == 'jruby' && p_addr = ENV_JAVA['http.proxyHost'] + p_port = ENV_JAVA['http.proxyPort'] + if p_user = ENV_JAVA['http.proxyUser'] + p_pass = ENV_JAVA['http.proxyPass'] + proxy_uri = "http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}" + else + proxy_uri = "http://#{p_addr}:#{p_port}" + end + else + unless proxy_uri = env[name] + if proxy_uri = env[name.upcase] + warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1 + end end end else -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/