faraday 2.14.4 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/faraday/connection.rb +10 -10
- data/lib/faraday/options/proxy_options.rb +2 -2
- data/lib/faraday/options.rb +2 -2
- data/lib/faraday/rack_builder.rb +1 -4
- data/lib/faraday/version.rb +1 -1
- data/spec/faraday/connection_spec.rb +37 -0
- data/spec/faraday/options/options_spec.rb +34 -0
- data/spec/faraday/options/proxy_options_spec.rb +6 -0
- data/spec/faraday/rack_builder_spec.rb +6 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c06dbc8aa2e38f23986579d5521da86fb335aaf0f5aa83db6fefb530e645b9f
|
|
4
|
+
data.tar.gz: 84db1e0a961b108e53db54277bc22f533a19f1abf3475384e09a396bf98969d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd4be1a725b5f287c0812ec1caa909c5338e938b697581d1bf585460fa47332d4dc840581edd726ff73fe2f4380fe65c45ba05fc92c98816954fe9ac356e0b23
|
|
7
|
+
data.tar.gz: a508f88684b8f60c9655ebec4acfc9e7cebe25982e708fc98be02d46357304c73ef408de7bba4e2c52b12229c76168c51d3cb9cc1e5728901d580bd6e986dca0
|
data/lib/faraday/connection.rb
CHANGED
|
@@ -210,7 +210,7 @@ module Faraday
|
|
|
210
210
|
#
|
|
211
211
|
# @overload options(url, params = nil, headers = nil)
|
|
212
212
|
# Makes an OPTIONS HTTP request to the given URL.
|
|
213
|
-
# @param url [String, URI, nil] String base URL to
|
|
213
|
+
# @param url [String, URI, nil] String base URL to use as a prefix for all requests.
|
|
214
214
|
# @param params [Hash, nil] Hash of URI query unencoded key/value pairs.
|
|
215
215
|
# @param headers [Hash, nil] unencoded HTTP header key/value pairs.
|
|
216
216
|
#
|
|
@@ -315,13 +315,13 @@ module Faraday
|
|
|
315
315
|
# @yield a block to execute multiple requests.
|
|
316
316
|
# @return [void]
|
|
317
317
|
def in_parallel(manager = nil, &block)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
318
|
+
previous_manager = @parallel_manager
|
|
319
|
+
@parallel_manager = manager || previous_manager || default_parallel_manager do
|
|
320
|
+
warn('Warning: `in_parallel` called but no parallel-capable adapter ' \
|
|
321
|
+
'on Faraday stack', caller[2, 10].join("\n"))
|
|
322
322
|
nil
|
|
323
323
|
end
|
|
324
|
-
return yield unless @parallel_manager
|
|
324
|
+
return yield unless @parallel_manager && !@parallel_manager.equal?(previous_manager)
|
|
325
325
|
|
|
326
326
|
if @parallel_manager.respond_to?(:execute)
|
|
327
327
|
# Execute is the new method that is responsible for executing the block.
|
|
@@ -332,7 +332,7 @@ module Faraday
|
|
|
332
332
|
@parallel_manager.run
|
|
333
333
|
end
|
|
334
334
|
ensure
|
|
335
|
-
@parallel_manager =
|
|
335
|
+
@parallel_manager = previous_manager
|
|
336
336
|
end
|
|
337
337
|
|
|
338
338
|
# Sets the Hash proxy options.
|
|
@@ -505,7 +505,7 @@ module Faraday
|
|
|
505
505
|
params: params.dup,
|
|
506
506
|
builder: builder.dup,
|
|
507
507
|
ssl: ssl.dup,
|
|
508
|
-
request: options.dup)
|
|
508
|
+
request: options.dup).tap { |copy| copy.proxy = proxy if @manual_proxy }
|
|
509
509
|
end
|
|
510
510
|
|
|
511
511
|
# Yields username and password extracted from a URI if they both exist.
|
|
@@ -519,7 +519,7 @@ module Faraday
|
|
|
519
519
|
def with_uri_credentials(uri)
|
|
520
520
|
return unless uri.user && uri.password
|
|
521
521
|
|
|
522
|
-
yield(
|
|
522
|
+
yield(URI::DEFAULT_PARSER.unescape(uri.user), URI::DEFAULT_PARSER.unescape(uri.password))
|
|
523
523
|
end
|
|
524
524
|
|
|
525
525
|
def proxy_from_env(url)
|
|
@@ -532,7 +532,7 @@ module Faraday
|
|
|
532
532
|
uri = if uri.host.nil?
|
|
533
533
|
find_default_proxy
|
|
534
534
|
else
|
|
535
|
-
URI.parse(
|
|
535
|
+
URI.parse(uri.to_s).find_proxy
|
|
536
536
|
end
|
|
537
537
|
when URI
|
|
538
538
|
uri = url.find_proxy
|
|
@@ -42,7 +42,7 @@ module Faraday
|
|
|
42
42
|
super
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
memoized(:user) { uri&.user &&
|
|
46
|
-
memoized(:password) { uri&.password &&
|
|
45
|
+
memoized(:user) { uri&.user && URI::DEFAULT_PARSER.unescape(uri.user) }
|
|
46
|
+
memoized(:password) { uri&.password && URI::DEFAULT_PARSER.unescape(uri.password) }
|
|
47
47
|
end
|
|
48
48
|
end
|
data/lib/faraday/options.rb
CHANGED
|
@@ -74,7 +74,7 @@ module Faraday
|
|
|
74
74
|
|
|
75
75
|
# Public
|
|
76
76
|
def fetch(key, *args)
|
|
77
|
-
unless
|
|
77
|
+
unless members.include?(key.to_sym) && !send(key).nil?
|
|
78
78
|
key_setter = "#{key}="
|
|
79
79
|
if !args.empty?
|
|
80
80
|
send(key_setter, args.first)
|
|
@@ -193,7 +193,7 @@ module Faraday
|
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
def symbolized_key_set
|
|
196
|
-
|
|
196
|
+
Set.new(keys.map(&:to_sym))
|
|
197
197
|
end
|
|
198
198
|
|
|
199
199
|
def self.inherited(subclass)
|
data/lib/faraday/rack_builder.rb
CHANGED
|
@@ -115,6 +115,7 @@ module Faraday
|
|
|
115
115
|
def adapter(klass = NO_ARGUMENT, *args, **kwargs, &block)
|
|
116
116
|
return @adapter if klass == NO_ARGUMENT || klass.nil?
|
|
117
117
|
|
|
118
|
+
raise_if_locked
|
|
118
119
|
klass = Faraday::Adapter.lookup_middleware(klass) if klass.is_a?(Symbol)
|
|
119
120
|
@adapter = self.class::Handler.new(klass, *args, **kwargs, &block)
|
|
120
121
|
end
|
|
@@ -230,10 +231,6 @@ module Faraday
|
|
|
230
231
|
raise MISSING_ADAPTER_ERROR unless @adapter
|
|
231
232
|
end
|
|
232
233
|
|
|
233
|
-
def adapter_set?
|
|
234
|
-
!@adapter.nil?
|
|
235
|
-
end
|
|
236
|
-
|
|
237
234
|
def use_symbol(mod, key, ...)
|
|
238
235
|
use(mod.lookup_middleware(key), ...)
|
|
239
236
|
end
|
data/lib/faraday/version.rb
CHANGED
|
@@ -119,6 +119,15 @@ RSpec.describe Faraday::Connection do
|
|
|
119
119
|
it { expect(subject.headers['Authorization']).to eq('Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==') }
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
+
context 'with basic_auth in url containing literal plus signs' do
|
|
123
|
+
let(:url) { 'http://Ala+ddin:open+sesame%2B@httpbingo.org/fish' }
|
|
124
|
+
|
|
125
|
+
it 'does not decode plus signs as spaces' do
|
|
126
|
+
expected = Faraday::Utils.basic_header_from('Ala+ddin', 'open+sesame+')
|
|
127
|
+
expect(subject.headers['Authorization']).to eq(expected)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
122
131
|
context 'with custom headers' do
|
|
123
132
|
let(:options) { { headers: { user_agent: 'Faraday' } } }
|
|
124
133
|
|
|
@@ -693,6 +702,34 @@ RSpec.describe Faraday::Connection do
|
|
|
693
702
|
it { expect(subject.options[:timeout]).to eq(5) }
|
|
694
703
|
it { expect(conn.options[:open_timeout]).to be_nil }
|
|
695
704
|
end
|
|
705
|
+
|
|
706
|
+
context 'with a manually set proxy' do
|
|
707
|
+
it 'preserves the proxy over env http_proxy' do
|
|
708
|
+
with_env 'http_proxy' => 'http://env-proxy.com' do
|
|
709
|
+
conn.proxy = 'http://manual-proxy.com'
|
|
710
|
+
|
|
711
|
+
expect(subject.proxy.host).to eq('manual-proxy.com')
|
|
712
|
+
expect(subject.proxy_for_request(url).host).to eq('manual-proxy.com')
|
|
713
|
+
end
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
it 'preserves an explicitly disabled proxy' do
|
|
717
|
+
with_env 'http_proxy' => 'http://env-proxy.com' do
|
|
718
|
+
conn.proxy = nil
|
|
719
|
+
|
|
720
|
+
expect(subject.proxy).to be_nil
|
|
721
|
+
expect(subject.proxy_for_request(url)).to be_nil
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
end
|
|
725
|
+
|
|
726
|
+
context 'without a manually set proxy' do
|
|
727
|
+
it 'uses env http_proxy' do
|
|
728
|
+
with_env 'http_proxy' => 'http://env-proxy.com' do
|
|
729
|
+
expect(subject.proxy_for_request(url).host).to eq('env-proxy.com')
|
|
730
|
+
end
|
|
731
|
+
end
|
|
732
|
+
end
|
|
696
733
|
end
|
|
697
734
|
|
|
698
735
|
describe '#respond_to?' do
|
|
@@ -277,6 +277,40 @@ RSpec.describe Faraday::Options do
|
|
|
277
277
|
it 'needs a default if key is missing' do
|
|
278
278
|
expect { subject.fetch(:sub_a) }.to raise_error(Faraday::Options.fetch_error_class)
|
|
279
279
|
end
|
|
280
|
+
|
|
281
|
+
it 'keeps the installed default on repeated fetches' do
|
|
282
|
+
expect(subject.fetch(:sub_a, 1)).to eq(1)
|
|
283
|
+
expect(subject.fetch(:sub_a, 2)).to eq(1)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
it 'reads the current value after a default is replaced' do
|
|
287
|
+
subject.fetch(:sub_a, 1)
|
|
288
|
+
subject.sub_a = 3
|
|
289
|
+
|
|
290
|
+
expect(subject.fetch(:sub_a, 2)).to eq(3)
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
it 'installs a new default after deletion or clearing' do
|
|
294
|
+
subject.fetch(:sub_a, 1)
|
|
295
|
+
subject.delete(:sub_a)
|
|
296
|
+
expect(subject.fetch(:sub_a, 2)).to eq(2)
|
|
297
|
+
|
|
298
|
+
subject.clear
|
|
299
|
+
expect(subject.fetch(:sub_a, 3)).to eq(3)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
it 'preserves a false value on later fetches' do
|
|
303
|
+
subject.fetch(:sub_a, false)
|
|
304
|
+
|
|
305
|
+
expect(subject.fetch(:sub_a, true) { :unused }).to be(false)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
it 'uses string keys and evaluates a block only for an empty value' do
|
|
309
|
+
expect(subject.fetch('sub_a') { |key| "#{key} default" }).to eq('sub_a default')
|
|
310
|
+
subject.sub_a = 'changed'
|
|
311
|
+
|
|
312
|
+
expect(subject.fetch('sub_a') { |key| raise "unexpected default for #{key}" }).to eq('changed')
|
|
313
|
+
end
|
|
280
314
|
end
|
|
281
315
|
|
|
282
316
|
context 'when the fetched key has a value' do
|
|
@@ -76,4 +76,10 @@ RSpec.describe Faraday::ProxyOptions do
|
|
|
76
76
|
expect(proxy.password).to eq('pw d')
|
|
77
77
|
expect(proxy[:password]).to eq('pw d')
|
|
78
78
|
end
|
|
79
|
+
|
|
80
|
+
it 'preserves literal plus signs in userinfo' do
|
|
81
|
+
proxy = Faraday::ProxyOptions.from 'http://a+b:pw+d%2B@example.org'
|
|
82
|
+
expect(proxy.user).to eq('a+b')
|
|
83
|
+
expect(proxy.password).to eq('pw+d+')
|
|
84
|
+
end
|
|
79
85
|
end
|
|
@@ -67,6 +67,12 @@ RSpec.describe Faraday::RackBuilder do
|
|
|
67
67
|
expect { subject.use(Orange) }.to raise_error(Faraday::RackBuilder::StackLocked)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
it 'rejects adapter changes after locking the stack' do
|
|
71
|
+
conn.get('/')
|
|
72
|
+
expect { subject.adapter(:net_http) }.to raise_error(Faraday::RackBuilder::StackLocked)
|
|
73
|
+
expect(subject.adapter).to eq(Faraday::Adapter.lookup_middleware(:test))
|
|
74
|
+
end
|
|
75
|
+
|
|
70
76
|
it 'dup stack is unlocked' do
|
|
71
77
|
expect(subject.locked?).to be_falsey
|
|
72
78
|
subject.lock!
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: faraday
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- "@technoweenie"
|
|
@@ -20,7 +20,7 @@ dependencies:
|
|
|
20
20
|
version: '2.0'
|
|
21
21
|
- - "<"
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: '3.
|
|
23
|
+
version: '3.6'
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -30,7 +30,7 @@ dependencies:
|
|
|
30
30
|
version: '2.0'
|
|
31
31
|
- - "<"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '3.
|
|
33
|
+
version: '3.6'
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: json
|
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -144,7 +144,7 @@ licenses:
|
|
|
144
144
|
- MIT
|
|
145
145
|
metadata:
|
|
146
146
|
homepage_uri: https://lostisland.github.io/faraday
|
|
147
|
-
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.
|
|
147
|
+
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.15.0
|
|
148
148
|
source_code_uri: https://github.com/lostisland/faraday
|
|
149
149
|
bug_tracker_uri: https://github.com/lostisland/faraday/issues
|
|
150
150
|
rubygems_mfa_required: 'true'
|