mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-05 00:05:35 -04:00
Add proxy setting when url_prefix is changed (#1276)
* Add proxy setting when url_prefix is changed Without this setting, setting the url_prefix after a Faraday::Connection is initialized results in no_proxy settings ignored when using relative paths. * Increase Rubocop Metrics/ClassLength
This commit is contained in:
parent
67c5f7b239
commit
53e4baedc7
@ -14,7 +14,7 @@ Metrics/AbcSize:
|
|||||||
# Offense count: 5
|
# Offense count: 5
|
||||||
# Configuration parameters: CountComments, CountAsOne.
|
# Configuration parameters: CountComments, CountAsOne.
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Max: 235
|
Max: 250
|
||||||
|
|
||||||
# Offense count: 15
|
# Offense count: 15
|
||||||
# Configuration parameters: IgnoredMethods.
|
# Configuration parameters: IgnoredMethods.
|
||||||
|
@ -419,6 +419,8 @@ module Faraday
|
|||||||
basic_auth user, password
|
basic_auth user, password
|
||||||
uri.user = uri.password = nil
|
uri.user = uri.password = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@proxy = proxy_from_env(url) unless @manual_proxy
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets the path prefix and ensures that it always has a leading
|
# Sets the path prefix and ensures that it always has a leading
|
||||||
@ -577,7 +579,11 @@ module Faraday
|
|||||||
case url
|
case url
|
||||||
when String
|
when String
|
||||||
uri = Utils.URI(url)
|
uri = Utils.URI(url)
|
||||||
uri = URI.parse("#{uri.scheme}://#{uri.host}").find_proxy
|
uri = if uri.host.nil?
|
||||||
|
find_default_proxy
|
||||||
|
else
|
||||||
|
URI.parse("#{uri.scheme}://#{uri.host}").find_proxy
|
||||||
|
end
|
||||||
when URI
|
when URI
|
||||||
uri = url.find_proxy
|
uri = url.find_proxy
|
||||||
when nil
|
when nil
|
||||||
|
@ -442,6 +442,14 @@ RSpec.describe Faraday::Connection do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'allows when url in no proxy list with url_prefix' do
|
||||||
|
with_env 'http_proxy' => 'http://proxy.com', 'no_proxy' => 'example.com' do
|
||||||
|
conn = Faraday::Connection.new
|
||||||
|
conn.url_prefix = 'http://example.com'
|
||||||
|
expect(conn.proxy).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'allows when prefixed url is not in no proxy list' do
|
it 'allows when prefixed url is not in no proxy list' do
|
||||||
with_env 'http_proxy' => 'http://proxy.com', 'no_proxy' => 'example.com' do
|
with_env 'http_proxy' => 'http://proxy.com', 'no_proxy' => 'example.com' do
|
||||||
conn = Faraday::Connection.new('http://prefixedexample.com')
|
conn = Faraday::Connection.new('http://prefixedexample.com')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user