faraday 1.3.0 → 1.4.1
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/CHANGELOG.md +30 -0
- data/README.md +1 -2
- data/lib/faraday.rb +2 -0
- data/lib/faraday/adapter.rb +0 -5
- data/lib/faraday/autoload.rb +0 -2
- data/lib/faraday/connection.rb +2 -1
- data/lib/faraday/version.rb +1 -1
- data/spec/faraday/connection_spec.rb +30 -0
- metadata +34 -9
- data/lib/faraday/adapter/excon.rb +0 -124
- data/lib/faraday/adapter/net_http_persistent.rb +0 -91
- data/spec/faraday/adapter/net_http_persistent_spec.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78d94069f3e1d41648f0b2c82872d305bf2c829667526d2c95f39f3a2609792e
|
4
|
+
data.tar.gz: 91e952182291cfc3311db77776811323980e00008966c8000259161c7a7e5294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfa2dc1f4c6d8a869f381a59c80babeadeb83b5201078eac30560f7b7bc6940464625c264db0c7ea2486d461edb6b197b07d37bf7b7bf7e517ff546332f1106e
|
7
|
+
data.tar.gz: bd4677f959813e83cb7f3f38369293ffd153b674c5dee1e45c8fe32e7796a84f047304e72c6b3b43fb90051ed91fd491bf5fb68344c729c07589eaf3b7513b2b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Faraday Changelog
|
2
2
|
|
3
|
+
## [v1.3.0](https://github.com/lostisland/faraday/releases/tag/v1.3.0) (2020-12-31)
|
4
|
+
|
5
|
+
### Highlights
|
6
|
+
Faraday v1.3.0 is the first release to officially support Ruby 3.0 in the CI pipeline 🎉 🍾!
|
7
|
+
|
8
|
+
This is also the first release with a previously "included" adapter (Net::HTTP) being isolated into a [separate gem](https://github.com/lostisland/faraday-net_http) 🎊!
|
9
|
+
The new adapter is added to Faraday as a dependency for now, so that means full backwards-compatibility, but just to be safe be careful when upgrading!
|
10
|
+
|
11
|
+
This is a huge step towards are Faraday v2.0 objective of pushing adapters and middleware into separate gems.
|
12
|
+
Many thanks to the Faraday Team, @JanDintel and everyone who attended the [ROSS Conf remote event](https://www.rossconf.io/event/remote/)
|
13
|
+
|
14
|
+
### Features
|
15
|
+
|
16
|
+
* Improves consistency with Faraday::Error and Faraday::RaiseError (#1229, @qsona, @iMacTia)
|
17
|
+
|
18
|
+
### Fixes
|
19
|
+
|
20
|
+
* Don't assign to global ::Timer (#1227, @bpo)
|
21
|
+
|
22
|
+
### Documentation
|
23
|
+
|
24
|
+
* CHANGELOG: add releases after 1.0 (#1225, @olleolleolle)
|
25
|
+
* Improves retry middleware documentation. (#1228, @iMacTia)
|
26
|
+
|
27
|
+
### Misc
|
28
|
+
|
29
|
+
* Move out Net::HTTP adapter (#1222, @JanDintel, @iMacTia)
|
30
|
+
* Adds Ruby 3.0 to CI Matrix (#1226, @iMacTia)
|
31
|
+
|
32
|
+
|
3
33
|
## [v1.2.0](https://github.com/lostisland/faraday/releases/tag/v1.2.0) (2020-12-23)
|
4
34
|
|
5
35
|
### Features
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/faraday)
|
4
4
|
[](https://github.com/lostisland/faraday/actions?query=workflow%3ACI)
|
5
|
-
[](https://codeclimate.com/github/lostisland/faraday/maintainability)
|
6
5
|
[](https://gitter.im/lostisland/faraday?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
7
6
|
|
8
7
|
|
@@ -47,7 +46,7 @@ But before you start coding, please read our [Contributing Guide][contributing]
|
|
47
46
|
[website]: https://lostisland.github.io/faraday
|
48
47
|
[faraday_team]: https://lostisland.github.io/faraday/team
|
49
48
|
[contributing]: https://github.com/lostisland/faraday/blob/master/.github/CONTRIBUTING.md
|
50
|
-
[apidoc]:
|
49
|
+
[apidoc]: https://www.rubydoc.info/github/lostisland/faraday
|
51
50
|
[actions]: https://github.com/lostisland/faraday/actions
|
52
51
|
[jruby]: http://jruby.org/
|
53
52
|
[rubinius]: http://rubini.us/
|
data/lib/faraday.rb
CHANGED
data/lib/faraday/adapter.rb
CHANGED
@@ -11,15 +11,10 @@ module Faraday
|
|
11
11
|
|
12
12
|
register_middleware File.expand_path('adapter', __dir__),
|
13
13
|
test: [:Test, 'test'],
|
14
|
-
net_http_persistent: [
|
15
|
-
:NetHttpPersistent,
|
16
|
-
'net_http_persistent'
|
17
|
-
],
|
18
14
|
typhoeus: [:Typhoeus, 'typhoeus'],
|
19
15
|
patron: [:Patron, 'patron'],
|
20
16
|
em_synchrony: [:EMSynchrony, 'em_synchrony'],
|
21
17
|
em_http: [:EMHttp, 'em_http'],
|
22
|
-
excon: [:Excon, 'excon'],
|
23
18
|
rack: [:Rack, 'rack'],
|
24
19
|
httpclient: [:HTTPClient, 'httpclient']
|
25
20
|
|
data/lib/faraday/autoload.rb
CHANGED
@@ -58,12 +58,10 @@ module Faraday
|
|
58
58
|
class Adapter
|
59
59
|
extend AutoloadHelper
|
60
60
|
autoload_all 'faraday/adapter',
|
61
|
-
NetHttpPersistent: 'net_http_persistent',
|
62
61
|
EMSynchrony: 'em_synchrony',
|
63
62
|
EMHttp: 'em_http',
|
64
63
|
Typhoeus: 'typhoeus',
|
65
64
|
Patron: 'patron',
|
66
|
-
Excon: 'excon',
|
67
65
|
Test: 'test',
|
68
66
|
Rack: 'rack',
|
69
67
|
HTTPClient: 'httpclient'
|
data/lib/faraday/connection.rb
CHANGED
@@ -522,6 +522,7 @@ module Faraday
|
|
522
522
|
base = base.dup
|
523
523
|
base.path = "#{base.path}/" # ensure trailing slash
|
524
524
|
end
|
525
|
+
url = url && URI.parse(url.to_s).opaque ? url.to_s.gsub(':', '%3A') : url
|
525
526
|
uri = url ? base + url : base
|
526
527
|
if params
|
527
528
|
uri.query = params.to_query(params_encoder || options.params_encoder)
|
@@ -576,7 +577,7 @@ module Faraday
|
|
576
577
|
case url
|
577
578
|
when String
|
578
579
|
uri = Utils.URI(url)
|
579
|
-
uri = URI.parse("#{uri.scheme}://#{uri.
|
580
|
+
uri = URI.parse("#{uri.scheme}://#{uri.host}").find_proxy
|
580
581
|
when URI
|
581
582
|
uri = url.find_proxy
|
582
583
|
when nil
|
data/lib/faraday/version.rb
CHANGED
@@ -18,6 +18,13 @@ shared_examples 'initializer with url' do
|
|
18
18
|
it { expect(subject.path_prefix).to eq('/fish') }
|
19
19
|
it { expect(subject.params).to eq('a' => '1') }
|
20
20
|
end
|
21
|
+
|
22
|
+
context 'with IPv6 address' do
|
23
|
+
let(:address) { 'http://[::1]:85/' }
|
24
|
+
|
25
|
+
it { expect(subject.host).to eq('[::1]') }
|
26
|
+
it { expect(subject.port).to eq(85) }
|
27
|
+
end
|
21
28
|
end
|
22
29
|
|
23
30
|
shared_examples 'default connection options' do
|
@@ -270,6 +277,29 @@ RSpec.describe Faraday::Connection do
|
|
270
277
|
expect(uri.to_s).to eq('http://sushi.com/sake/')
|
271
278
|
end
|
272
279
|
end
|
280
|
+
|
281
|
+
context 'with colon in path' do
|
282
|
+
let(:url) { 'http://service.com' }
|
283
|
+
|
284
|
+
it 'joins url to base when used absolute path' do
|
285
|
+
conn = Faraday.new(url: url)
|
286
|
+
uri = conn.build_exclusive_url('/service:search?limit=400')
|
287
|
+
expect(uri.to_s).to eq('http://service.com/service:search?limit=400')
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'joins url to base when used relative path' do
|
291
|
+
conn = Faraday.new(url: url)
|
292
|
+
uri = conn.build_exclusive_url('service:search?limit=400')
|
293
|
+
expect(uri.to_s).to eq('http://service.com/service%3Asearch?limit=400')
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'joins url to base when used with path prefix' do
|
297
|
+
conn = Faraday.new(url: url)
|
298
|
+
conn.path_prefix = '/api'
|
299
|
+
uri = conn.build_exclusive_url('service:search?limit=400')
|
300
|
+
expect(uri.to_s).to eq('http://service.com/api/service%3Asearch?limit=400')
|
301
|
+
end
|
302
|
+
end
|
273
303
|
end
|
274
304
|
|
275
305
|
describe '#build_url' do
|
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: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "@technoweenie"
|
@@ -10,8 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-04-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: faraday-excon
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.1'
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: faraday-net_http
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -26,6 +40,20 @@ dependencies:
|
|
26
40
|
- - "~>"
|
27
41
|
- !ruby/object:Gem::Version
|
28
42
|
version: '1.0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: faraday-net_http_persistent
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.1'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.1'
|
29
57
|
- !ruby/object:Gem::Dependency
|
30
58
|
name: multipart-post
|
31
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,14 +80,14 @@ dependencies:
|
|
52
80
|
requirements:
|
53
81
|
- - ">="
|
54
82
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
83
|
+
version: 0.0.4
|
56
84
|
type: :runtime
|
57
85
|
prerelease: false
|
58
86
|
version_requirements: !ruby/object:Gem::Requirement
|
59
87
|
requirements:
|
60
88
|
- - ">="
|
61
89
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
90
|
+
version: 0.0.4
|
63
91
|
description:
|
64
92
|
email: technoweenie@gmail.com
|
65
93
|
executables: []
|
@@ -78,9 +106,7 @@ files:
|
|
78
106
|
- lib/faraday/adapter/em_http_ssl_patch.rb
|
79
107
|
- lib/faraday/adapter/em_synchrony.rb
|
80
108
|
- lib/faraday/adapter/em_synchrony/parallel_manager.rb
|
81
|
-
- lib/faraday/adapter/excon.rb
|
82
109
|
- lib/faraday/adapter/httpclient.rb
|
83
|
-
- lib/faraday/adapter/net_http_persistent.rb
|
84
110
|
- lib/faraday/adapter/patron.rb
|
85
111
|
- lib/faraday/adapter/rack.rb
|
86
112
|
- lib/faraday/adapter/test.rb
|
@@ -126,7 +152,6 @@ files:
|
|
126
152
|
- spec/faraday/adapter/em_synchrony_spec.rb
|
127
153
|
- spec/faraday/adapter/excon_spec.rb
|
128
154
|
- spec/faraday/adapter/httpclient_spec.rb
|
129
|
-
- spec/faraday/adapter/net_http_persistent_spec.rb
|
130
155
|
- spec/faraday/adapter/net_http_spec.rb
|
131
156
|
- spec/faraday/adapter/patron_spec.rb
|
132
157
|
- spec/faraday/adapter/rack_spec.rb
|
@@ -172,7 +197,7 @@ licenses:
|
|
172
197
|
- MIT
|
173
198
|
metadata:
|
174
199
|
homepage_uri: https://lostisland.github.io/faraday
|
175
|
-
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v1.
|
200
|
+
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v1.4.1
|
176
201
|
source_code_uri: https://github.com/lostisland/faraday
|
177
202
|
bug_tracker_uri: https://github.com/lostisland/faraday/issues
|
178
203
|
post_install_message:
|
@@ -191,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
216
|
- !ruby/object:Gem::Version
|
192
217
|
version: '0'
|
193
218
|
requirements: []
|
194
|
-
rubygems_version: 3.0.3
|
219
|
+
rubygems_version: 3.0.3.1
|
195
220
|
signing_key:
|
196
221
|
specification_version: 4
|
197
222
|
summary: HTTP/REST API client library.
|
@@ -1,124 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Faraday
|
4
|
-
class Adapter
|
5
|
-
# Excon adapter.
|
6
|
-
class Excon < Faraday::Adapter
|
7
|
-
dependency 'excon'
|
8
|
-
|
9
|
-
def build_connection(env)
|
10
|
-
opts = opts_from_env(env)
|
11
|
-
::Excon.new(env[:url].to_s, opts.merge(@connection_options))
|
12
|
-
end
|
13
|
-
|
14
|
-
def call(env)
|
15
|
-
super
|
16
|
-
|
17
|
-
req_opts = {
|
18
|
-
method: env[:method].to_s.upcase,
|
19
|
-
headers: env[:request_headers],
|
20
|
-
body: read_body(env)
|
21
|
-
}
|
22
|
-
|
23
|
-
req = env[:request]
|
24
|
-
if req&.stream_response?
|
25
|
-
total = 0
|
26
|
-
req_opts[:response_block] = lambda do |chunk, _remain, _total|
|
27
|
-
req.on_data.call(chunk, total += chunk.size)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
resp = connection(env) { |http| http.request(req_opts) }
|
32
|
-
save_response(env, resp.status.to_i, resp.body, resp.headers,
|
33
|
-
resp.reason_phrase)
|
34
|
-
|
35
|
-
@app.call(env)
|
36
|
-
rescue ::Excon::Errors::SocketError => e
|
37
|
-
raise Faraday::TimeoutError, e if e.message.match?(/\btimeout\b/)
|
38
|
-
|
39
|
-
raise Faraday::SSLError, e if e.message.match?(/\bcertificate\b/)
|
40
|
-
|
41
|
-
raise Faraday::ConnectionFailed, e
|
42
|
-
rescue ::Excon::Errors::Timeout => e
|
43
|
-
raise Faraday::TimeoutError, e
|
44
|
-
end
|
45
|
-
|
46
|
-
# TODO: support streaming requests
|
47
|
-
def read_body(env)
|
48
|
-
env[:body].respond_to?(:read) ? env[:body].read : env[:body]
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def opts_from_env(env)
|
54
|
-
opts = {}
|
55
|
-
amend_opts_with_ssl!(opts, env[:ssl]) if needs_ssl_settings?(env)
|
56
|
-
|
57
|
-
if (req = env[:request])
|
58
|
-
amend_opts_with_timeouts!(opts, req)
|
59
|
-
amend_opts_with_proxy_settings!(opts, req)
|
60
|
-
end
|
61
|
-
|
62
|
-
opts
|
63
|
-
end
|
64
|
-
|
65
|
-
def needs_ssl_settings?(env)
|
66
|
-
env[:url].scheme == 'https' && env[:ssl]
|
67
|
-
end
|
68
|
-
|
69
|
-
OPTS_KEYS = [
|
70
|
-
%i[client_cert client_cert],
|
71
|
-
%i[client_key client_key],
|
72
|
-
%i[certificate certificate],
|
73
|
-
%i[private_key private_key],
|
74
|
-
%i[ssl_ca_path ca_path],
|
75
|
-
%i[ssl_ca_file ca_file],
|
76
|
-
%i[ssl_version version],
|
77
|
-
%i[ssl_min_version min_version],
|
78
|
-
%i[ssl_max_version max_version]
|
79
|
-
].freeze
|
80
|
-
|
81
|
-
def amend_opts_with_ssl!(opts, ssl)
|
82
|
-
opts[:ssl_verify_peer] = !!ssl.fetch(:verify, true)
|
83
|
-
# https://github.com/geemus/excon/issues/106
|
84
|
-
# https://github.com/jruby/jruby-ossl/issues/19
|
85
|
-
opts[:nonblock] = false
|
86
|
-
|
87
|
-
OPTS_KEYS.each do |(key_in_opts, key_in_ssl)|
|
88
|
-
next unless ssl[key_in_ssl]
|
89
|
-
|
90
|
-
opts[key_in_opts] = ssl[key_in_ssl]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def amend_opts_with_timeouts!(opts, req)
|
95
|
-
if (sec = request_timeout(:read, req))
|
96
|
-
opts[:read_timeout] = sec
|
97
|
-
end
|
98
|
-
|
99
|
-
if (sec = request_timeout(:write, req))
|
100
|
-
opts[:write_timeout] = sec
|
101
|
-
end
|
102
|
-
|
103
|
-
return unless (sec = request_timeout(:open, req))
|
104
|
-
|
105
|
-
opts[:connect_timeout] = sec
|
106
|
-
end
|
107
|
-
|
108
|
-
def amend_opts_with_proxy_settings!(opts, req)
|
109
|
-
opts[:proxy] = proxy_settings_for_opts(req[:proxy]) if req[:proxy]
|
110
|
-
end
|
111
|
-
|
112
|
-
def proxy_settings_for_opts(proxy)
|
113
|
-
{
|
114
|
-
host: proxy[:uri].host,
|
115
|
-
hostname: proxy[:uri].hostname,
|
116
|
-
port: proxy[:uri].port,
|
117
|
-
scheme: proxy[:uri].scheme,
|
118
|
-
user: proxy[:user],
|
119
|
-
password: proxy[:password]
|
120
|
-
}
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Faraday
|
4
|
-
class Adapter
|
5
|
-
# Net::HTTP::Persistent adapter.
|
6
|
-
class NetHttpPersistent < NetHttp
|
7
|
-
dependency 'net/http/persistent'
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def net_http_connection(env)
|
12
|
-
@cached_connection ||=
|
13
|
-
if Net::HTTP::Persistent.instance_method(:initialize)
|
14
|
-
.parameters.first == %i[key name]
|
15
|
-
options = { name: 'Faraday' }
|
16
|
-
if @connection_options.key?(:pool_size)
|
17
|
-
options[:pool_size] = @connection_options[:pool_size]
|
18
|
-
end
|
19
|
-
Net::HTTP::Persistent.new(**options)
|
20
|
-
else
|
21
|
-
Net::HTTP::Persistent.new('Faraday')
|
22
|
-
end
|
23
|
-
|
24
|
-
proxy_uri = proxy_uri(env)
|
25
|
-
if @cached_connection.proxy_uri != proxy_uri
|
26
|
-
@cached_connection.proxy = proxy_uri
|
27
|
-
end
|
28
|
-
@cached_connection
|
29
|
-
end
|
30
|
-
|
31
|
-
def proxy_uri(env)
|
32
|
-
proxy_uri = nil
|
33
|
-
if (proxy = env[:request][:proxy])
|
34
|
-
proxy_uri = if proxy[:uri].is_a?(::URI::HTTP)
|
35
|
-
proxy[:uri].dup
|
36
|
-
else
|
37
|
-
::URI.parse(proxy[:uri].to_s)
|
38
|
-
end
|
39
|
-
proxy_uri.user = proxy_uri.password = nil
|
40
|
-
# awful patch for net-http-persistent 2.8
|
41
|
-
# not unescaping user/password
|
42
|
-
if proxy[:user]
|
43
|
-
(class << proxy_uri; self; end).class_eval do
|
44
|
-
define_method(:user) { proxy[:user] }
|
45
|
-
define_method(:password) { proxy[:password] }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
proxy_uri
|
50
|
-
end
|
51
|
-
|
52
|
-
def perform_request(http, env)
|
53
|
-
http.request env[:url], create_request(env)
|
54
|
-
rescue Errno::ETIMEDOUT, Net::OpenTimeout => e
|
55
|
-
raise Faraday::TimeoutError, e
|
56
|
-
rescue Net::HTTP::Persistent::Error => e
|
57
|
-
raise Faraday::TimeoutError, e if e.message.include? 'Timeout'
|
58
|
-
|
59
|
-
if e.message.include? 'connection refused'
|
60
|
-
raise Faraday::ConnectionFailed, e
|
61
|
-
end
|
62
|
-
|
63
|
-
raise
|
64
|
-
end
|
65
|
-
|
66
|
-
SSL_CONFIGURATIONS = {
|
67
|
-
certificate: :client_cert,
|
68
|
-
private_key: :client_key,
|
69
|
-
ca_file: :ca_file,
|
70
|
-
ssl_version: :version,
|
71
|
-
min_version: :min_version,
|
72
|
-
max_version: :max_version
|
73
|
-
}.freeze
|
74
|
-
|
75
|
-
def configure_ssl(http, ssl)
|
76
|
-
return unless ssl
|
77
|
-
|
78
|
-
http_set(http, :verify_mode, ssl_verify_mode(ssl))
|
79
|
-
http_set(http, :cert_store, ssl_cert_store(ssl))
|
80
|
-
|
81
|
-
SSL_CONFIGURATIONS
|
82
|
-
.select { |_, key| ssl[key] }
|
83
|
-
.each { |target, key| http_set(http, target, ssl[key]) }
|
84
|
-
end
|
85
|
-
|
86
|
-
def http_set(http, attr, value)
|
87
|
-
http.send("#{attr}=", value) if http.send(attr) != value
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Faraday::Adapter::NetHttpPersistent do
|
4
|
-
features :request_body_on_query_methods, :reason_phrase_parse, :compression, :trace_method
|
5
|
-
|
6
|
-
it_behaves_like 'an adapter'
|
7
|
-
|
8
|
-
it 'allows to provide adapter specific configs' do
|
9
|
-
url = URI('https://example.com')
|
10
|
-
|
11
|
-
adapter = described_class.new do |http|
|
12
|
-
http.idle_timeout = 123
|
13
|
-
end
|
14
|
-
|
15
|
-
http = adapter.send(:connection, url: url, request: {})
|
16
|
-
adapter.send(:configure_request, http, {})
|
17
|
-
|
18
|
-
expect(http.idle_timeout).to eq(123)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'sets max_retries to 0' do
|
22
|
-
url = URI('http://example.com')
|
23
|
-
|
24
|
-
adapter = described_class.new
|
25
|
-
|
26
|
-
http = adapter.send(:connection, url: url, request: {})
|
27
|
-
adapter.send(:configure_request, http, {})
|
28
|
-
|
29
|
-
# `max_retries=` is only present in Ruby 2.5
|
30
|
-
expect(http.max_retries).to eq(0) if http.respond_to?(:max_retries=)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'allows to set pool_size on initialize' do
|
34
|
-
url = URI('https://example.com')
|
35
|
-
|
36
|
-
adapter = described_class.new(nil, pool_size: 5)
|
37
|
-
|
38
|
-
http = adapter.send(:connection, url: url, request: {})
|
39
|
-
|
40
|
-
# `pool` is only present in net_http_persistent >= 3.0
|
41
|
-
expect(http.pool.size).to eq(5) if http.respond_to?(:pool)
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'min_version' do
|
45
|
-
it 'allows to set min_version in SSL settings' do
|
46
|
-
url = URI('https://example.com')
|
47
|
-
|
48
|
-
adapter = described_class.new(nil)
|
49
|
-
|
50
|
-
http = adapter.send(:connection, url: url, request: {})
|
51
|
-
adapter.send(:configure_ssl, http, min_version: :TLS1_2)
|
52
|
-
|
53
|
-
# `min_version` is only present in net_http_persistent >= 3.1 (UNRELEASED)
|
54
|
-
expect(http.min_version).to eq(:TLS1_2) if http.respond_to?(:min_version)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|