net-http
net-http copied to clipboard
fail to fetch proxy user/pw from env variable
http.rb use RUBY_PLATFORM to decide the source of username/ password of the proxy. RUBY_PLATFORM of jruby is java
. It blocks jruby user from using proxy with env variable
ruby --version jruby 9.3.6.0 (2.6.8) 2022-06-27 7a2cbcd376 OpenJDK 64-Bit Server VM 11.0.15+10 on 11.0.15+10 +jit [x86_64-darwin]
reproduce steps
- export JRUBY_OPTS='-J-Dhttps.proxyHost=user:pw@host -J-Dhttps.proxyPort=3128 -J-Dhttp.proxyHost=user:pw@host -J-Dhttp.proxyPort=3128'
- ruby -e "require 'net/http'; uri = URI('https://www.google.com'); Net::HTTP.get(uri);"
log
Net::HTTPServerException: 407 "Proxy Authentication Required"
error! at /Users/kcheng/.rbenv/versions/jruby-9.3.6.0/lib/ruby/stdlib/net/http/response.rb:122
value at /Users/kcheng/.rbenv/versions/jruby-9.3.6.0/lib/ruby/stdlib/net/http/response.rb:131
connect at /Users/kcheng/.rbenv/versions/jruby-9.3.6.0/lib/ruby/stdlib/net/http.rb:973
do_start at /Users/kcheng/.rbenv/versions/jruby-9.3.6.0/lib/ruby/stdlib/net/http.rb:934
start at /Users/kcheng/.rbenv/versions/jruby-9.3.6.0/lib/ruby/stdlib/net/http.rb:923
start at /Users/kcheng/.rbenv/versions/jruby-9.3.6.0/lib/ruby/stdlib/net/http.rb:605
get_response at /Users/kcheng/.rbenv/versions/jruby-9.3.6.0/lib/ruby/stdlib/net/http.rb:481
get at /Users/kcheng/.rbenv/versions/jruby-9.3.6.0/lib/ruby/stdlib/net/http.rb:458
<main> at -e:1
removing ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE will solve the issue