强制所有 http 请求遵循系统代理配置
我正在使用一个 ruby 应用程序,该应用程序使用一些与 Web 服务交互的松散耦合模块。这些模块使用ruby的net::http模块进行网络通信。但原始代码无法指定代理配置。当然,ruby 的 net::http 不尊重系统代理配置。
我想知道是否有一种方法可以通过路径变量“http_proxy”指定的代理服务器对所有 http 请求进行通道化,而无需更改这些模块。 (这些模块是单独维护的,进行艰难的更改会使将来更新它们时变得困难)
任何帮助将不胜感激。
I am working with a ruby application that uses some loosely coupled modules that interface with a web service. These modules use net::http module of ruby for network communication. But the original code has no means to specify proxy configurations. And of course ruby's net::http does not respect system proxy configuration.
I would like to know if there is a way to channelize all the http requests through the proxy server specified by path variable 'http_proxy' without changing these modules. (These modules are separately maintained and making hard changes would make things difficult while updating them in future)
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我确实遇到了这个问题,似乎 ruby-proxifier 是一个宝石,应该能够帮助解决这个问题:
https://github.com/samuelkadolph/ruby-proxifier
I had exactly this problem and it seems that the ruby-proxifier is a gem that ought to be able to help with this:
https://github.com/samuelkadolph/ruby-proxifier