httparty icon indicating copy to clipboard operation
httparty copied to clipboard

Impossible to use Net::HTTP option for ignoring proxy set in environment

Open rubyconvict opened this issue 11 years ago • 2 comments

L: 73 lib/httparty/connection_adapter.rb

    def connection
      host = clean_host(uri.host)
      if options[:http_proxyaddr]
        http = Net::HTTP.new(host, uri.port, options[:http_proxyaddr], options[:http_proxyport], options[:http_proxyuser], options[:http_proxypass])
      else
        http = Net::HTTP.new(host, uri.port)
      end

http://ruby-doc.org/stdlib-2.1.2/libdoc/net/http/rdoc/Net/HTTP.html#method-c-new

one must pass nil to proxy address to disable the usage of proxy_from_env

Solution: drop the if statement, Net::HTTP.new will accept nil's

rubyconvict avatar Aug 25 '14 13:08 rubyconvict

Pretty sure the if was added to fix some issue. Maybe it only affected older versions of ruby?

jnunemaker avatar Aug 25 '14 15:08 jnunemaker

1.8.7, 1.9.3, 2.1.2 - net http changed a bit, but the concept was the same, one could and should be able to pass nil to bypass environmental proxy. It's like curl --proxy '' google.com, core feature...

rubyconvict avatar Aug 26 '14 19:08 rubyconvict