summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Oliver Nutter <headius@headius.com>2021-03-04 16:44:35 -0600
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-04-22 14:54:19 +0900
commit6e06c980dace26ff2f06eb4ac1e2d06291101ee7 (patch)
treef5e07dc7f54a813c26f7b76e334da7a4eb4a6d54
parenta9fe00c3baf26b94d924149e99334f4d587e125e (diff)
[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
-rw-r--r--lib/uri/generic.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index a4192c6557..7de62b66db 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -1514,9 +1514,19 @@ module URI
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