-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Net::HTTP can't ignore http.proxyHost of JVM System Property #2983
Comments
I thought we had added logic to net/http to honor this. Perhaps it was lost? |
Are you taking about this? #195 or d04857c#diff-49 I confirmed that Net::HTTP can ignore http.proxyHost at 2.0 mode. |
I do see the same logic (using ...
#
# In JRuby, this will default to the JSE proxy settings provided in the
# 'http.proxyHost' and 'http.proxyPort' Java system properties, if they
# are set and no alternative proxy has been provided.
#
def HTTP.new(address, port = nil, p_addr = ENV_JAVA['http.proxyHost'], p_port = ENV_JAVA['http.proxyPort'], p_user = nil, p_pass = nil)
http = super address, port
if proxy_class? then # from Net::HTTP::Proxy()
... |
I'm using ActiveResource. ex) #main.rb
require 'bundler'
Bundler.require
require 'active_resource'
# for debug
class ActiveResource::Connection
alias_method :new_http_without_debug, :new_http
def new_http(*args)
new_http_without_debug(*args).tap{|h| h.set_debug_output($stderr)}
end
end
# my model
class MyModel < ActiveResource::Base
self.site = 'http://localhost:9292'
self.proxy = nil
end
p RUBY_VERSION
if defined?(ENV_JAVA)
p ENV_JAVA.values_at *%w(http.proxyHost http.proxyPort http.nonProxyHosts)
end
p MyModel.all
2.0 mode has the same result. |
Ok, so if I understand right, the proxy is being used, but it's not being ignored based on your ignore spec...correct? |
So here's what I think we need to do.
The first change will take some time to get into Ruby versions, and will need to be filed with ruby-core at http://bugs.ruby-lang.org. Luckily, I'm also a ruby-core committer so I should be able to help usher it through. The second change can be done in any version of JRuby, but I'm working on doing it in such a way that it doesn't break the current logic for defaulting to ENV_JAVA values. |
I believe I have (2)[https://github.com//issues/2983#issuecomment-106601849] above implemented. Here's the output from your script before and after my change, with Before:
After:
Here's the diff. We'd apply this to |
I have filed a bug with MRI to get my changes incorporated, in whole or in part, back into MRI stdlib: https://bugs.ruby-lang.org/issues/11194 I filed a separate issue to add a |
It's the behavior that I wanted. |
I will apply the diff to JRuby 1.7 and 9k for next releases, and work separately with MRI to get the changes upstream. |
Ok, so the problem I run into is that the ENV support in net/http did not arrive until 2.0, so the 1.9 net/http.rb and uri/generic.rb do not have the code needed for this. We can apply to the 2.0 stdlib, but we have generally not backported code that ruby-core has not opted to backport themselves. JRuby 1.7.21 will support it in the (experimental) 2.0 mode and JRuby 9k will support it normally. |
Fixes #2983. Note that Ruby 1.9 has no support for environment-driven proxy settings, so this change is only available in 2.0 mode on JRuby 1.7.
thank you. 👍 |
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
example code & exec result
The text was updated successfully, but these errors were encountered: