Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/net/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,8 @@ def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_p
if p_addr && p_no_proxy && !URI::Generic.use_proxy?(address, address, port, p_no_proxy)
p_addr = nil
p_port = nil
p_user = nil
p_pass = nil
end
http.proxy_address = p_addr
http.proxy_port = p_port || default_port
Expand Down
12 changes: 12 additions & 0 deletions test/net/http/test_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ def test_proxy_address_no_proxy
end
end

def test_proxy_user_no_proxy
TestNetHTTPUtils.clean_http_proxy_env do
http = Net::HTTP.new 'hostname.example', nil, 'proxy.com', nil, 'user', 'pass', 'example'
assert_nil http.proxy_user
assert_nil http.proxy_pass

http = Net::HTTP.new 'hostname.other', nil, 'proxy.com', nil, 'user', 'pass', 'example'
assert_equal 'user', http.proxy_user
assert_equal 'pass', http.proxy_pass
end
end

def test_proxy_from_env_ENV
TestNetHTTPUtils.clean_http_proxy_env do
ENV['http_proxy'] = 'http://proxy.example:8000'
Expand Down
Loading