让 JRuby 继承 Java 代理设置
我想从 JRuby 之上运行的 Rails 代码发出 HTTP 请求。
如何让它重用给运行它的 JVM 的 http.proxyHost、http.proxyPort 和 http.nonProxyHosts 设置?
I would like to make HTTP requests from Rails code running on top of JRuby.
How can I make it to re-use http.proxyHost, http.proxyPort and http.nonProxyHosts settings, given to JVM running it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要通过 JRuby 传递 JVM 标志,请使用
-J...
。在这种情况下:JRuby 的帮助文本对此进行了解释。
To pass JVM flags through JRuby, use
-J...
. In this case:This is explained in JRuby's help text.
我也有同样的问题。我发现 java 或 net::http 不遵守 nonProxyHosts 选项。解决这个问题的最佳方法是修改 ENV_JAVA 设置来解决这个问题。
我为确保使用 nonProxyHosts 所采取的步骤如下:
请记住,至少对于 java1.7,nonProxyHosts 不应包含引号,请参阅 此处。
现在我发现 net::http 或 java 本身实际上并不支持 nonProxyHosts 选项。
不过,您可以通过在 JRuby 中执行以下操作来解决此问题,
希望有所帮助。
I have had the same issue. I found that java or net::http doesn't obey the nonProxyHosts option. The best way to get around this is to modify the ENV_JAVA settings to account for this.
The steps I took to ensure nonProxyHosts was used were the following:
Keep in mind that at least for java1.7 the nonProxyHosts should not have quotations see here.
Now I find that either net::http or java itself doesn't actually honour the nonProxyHosts option.
However you can get around this by doing the following in JRuby
Hope that helps.