Skip to content

Commit

Permalink
Merge pull request #457 from pic/feature/nil_http_proxyaddr
Browse files Browse the repository at this point in the history
Allow nil http_proxyaddr to pass through to Net::HTTP
  • Loading branch information
greatuserongithub committed Jan 13, 2016
2 parents 3fe80eb + 0737313 commit 41d0477
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/httparty/connection_adapter.rb
Expand Up @@ -76,7 +76,7 @@ def initialize(uri, options = {})
def connection
host = clean_host(uri.host)
port = uri.port || (uri.scheme == 'https' ? 443 : 80)
if options[:http_proxyaddr]
if options.has_key?(:http_proxyaddr)
http = Net::HTTP.new(host, port, options[:http_proxyaddr], options[:http_proxyport], options[:http_proxyuser], options[:http_proxypass])
else
http = Net::HTTP.new(host, port)
Expand Down
13 changes: 13 additions & 0 deletions spec/httparty/connection_adapter_spec.rb
Expand Up @@ -325,6 +325,19 @@
end
end

context 'when providing nil as proxy address' do
let(:uri) { URI 'http://noproxytest.com' }
let(:options) { {http_proxyaddr: nil} }

it { is_expected.not_to be_a_proxy }

it "does pass nil proxy parameters to the connection, this forces to not use a proxy" do
http = Net::HTTP.new("noproxytest.com")
expect(Net::HTTP).to receive(:new).once.with("noproxytest.com", 80, nil, nil, nil, nil).and_return(http)
adapter.connection
end
end

context 'when not providing a proxy address' do
let(:uri) { URI 'http://proxytest.com' }

Expand Down

0 comments on commit 41d0477

Please sign in to comment.