Skip to content

Commit

Permalink
Upstream Java proxy property checks from JRuby
Browse files Browse the repository at this point in the history
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
  • Loading branch information
headius authored and jeremyevans committed Mar 4, 2021
1 parent 44004f1 commit 3bd2bcc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/uri/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1514,9 +1514,19 @@ def find_proxy(env=ENV)
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
Expand Down

0 comments on commit 3bd2bcc

Please sign in to comment.