Skip to content

Net::HTTP can't ignore http.proxyHost of JVM System Property #2983

@yousuketto

Description

@yousuketto

JRuby ignores http.nonProxyHosts of JVM System Property.
Therefore I think that there are no way to access without http proxy, when there are http.proxyHost.

my env

  • I set http proxy in mac system settings
    • this probably set http.proxyHost, http.proxyPort and http.nonProxyHosts.
$ jruby -e "puts ENV_JAVA.values_at *%w(http.proxyHost http.proxyPort http.nonProxyHosts)"
xxx.example.com
8080
localhost|*.localhost
  • oracle jdk8
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
  • jruby 1.7.20

example code & exec result

#example.rb
require 'net/http'
http = Net::HTTP.new("localhost", 9292, nil, nil)
http.set_debug_output($stderr)
res = http.get("/")
p res.body
$ jruby example.rb 
opening connection to xxx.example.com...
opened
<- "GET http://localhost:9292/ HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: localhost:9292\r\n\r\n"
Conn close because of error Timeout::Error
Timeout::Error: Timeout::Error
          rbuf_fill at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/protocol.rb:146
          readuntil at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/protocol.rb:122
           readline at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/protocol.rb:132
   read_status_line at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:2571
           read_new at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:2560
  transport_request at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:1328
              catch at org/jruby/RubyKernel.java:1274
  transport_request at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:1325
            request at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:1302
            request at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:1295
              start at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:746
            request at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:1293
                get at /Users/user/.rvm/rubies/jruby-1.7.20/lib/ruby/1.9/net/http.rb:1035
             (root) at example.rb:5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions