mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Merge pull request #457 from pic/feature/nil_http_proxyaddr
Allow nil http_proxyaddr to pass through to Net::HTTP
This commit is contained in:
commit
41d0477f1f
2 changed files with 14 additions and 1 deletions
|
@ -76,7 +76,7 @@ module HTTParty
|
|||
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)
|
||||
|
|
|
@ -325,6 +325,19 @@ RSpec.describe HTTParty::ConnectionAdapter do
|
|||
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' }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue