oauth-xx/oauth-ruby

Use the default environment variable "http_proxy"

nathanvda opened this issue · 2 comments

I am getting connection problems with some ruby code installed at a client of mine.

Their server is behind a proxy, but normally the only thing I have to do is specify the http_proxy environment. I was checking the code and noticed we have to specify the proxy option.

Is there a specific reason to not use/check the environment variable? In other words: would a pull request that would do that be considered?

Just weighing my options here: it would be very easy to just provide the proxy in the constructor, but it seems "cleaner" if it would just use the environment variables, but I feel I am overlooking some reason to not use it?

Please experiment and report back! A PR to add support for an environment variable would be appreciated!

Thank you for your feedback. Old ticket, so I had to go digging how I solved/handled this.

My specific use-case was that I created a gem to contact the MoreApp API. So in my gem, which depends on your gem,
I solved this case using the following approach in my library:

@consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {
               site: MoreappAPI.api_base], 
               proxy: options[:proxy] || options["proxy"] || ENV['http_proxy'] || ENV["HTTP_PROXY"] 
})

which for my purposes solves all cases. Either a user can specify an explicit proxy, or I look for the environment variables or we do not use a proxy. I guess most people will be using such an approach, so not sure if there is still a need for this ticket.