faraday 1.0.0 → 1.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +104 -0
- data/LICENSE.md +1 -1
- data/README.md +4 -6
- data/examples/client_spec.rb +35 -3
- data/examples/client_test.rb +41 -2
- data/lib/faraday/adapter/test.rb +59 -43
- data/lib/faraday/adapter/typhoeus.rb +1 -1
- data/lib/faraday/adapter.rb +2 -12
- data/lib/faraday/adapter_registry.rb +3 -1
- data/lib/faraday/autoload.rb +2 -10
- data/lib/faraday/connection.rb +37 -9
- data/lib/faraday/dependency_loader.rb +3 -1
- data/lib/faraday/deprecate.rb +110 -0
- data/lib/faraday/encoders/flat_params_encoder.rb +9 -2
- data/lib/faraday/encoders/nested_params_encoder.rb +7 -2
- data/lib/faraday/error.rb +20 -6
- data/lib/faraday/methods.rb +6 -0
- data/lib/faraday/middleware.rb +14 -4
- data/lib/faraday/options/proxy_options.rb +4 -0
- data/lib/faraday/options.rb +4 -8
- data/lib/faraday/rack_builder.rb +13 -12
- data/lib/faraday/request/authorization.rb +17 -8
- data/lib/faraday/request/json.rb +55 -0
- data/lib/faraday/request/url_encoded.rb +3 -1
- data/lib/faraday/request.rb +19 -11
- data/lib/faraday/response/json.rb +54 -0
- data/lib/faraday/response/logger.rb +2 -4
- data/lib/faraday/response/raise_error.rb +12 -1
- data/lib/faraday/response.rb +7 -8
- data/lib/faraday/utils/headers.rb +2 -2
- data/lib/faraday/utils.rb +11 -3
- data/lib/faraday/version.rb +5 -0
- data/lib/faraday.rb +67 -40
- data/spec/faraday/adapter/em_http_spec.rb +39 -37
- data/spec/faraday/adapter/em_synchrony_spec.rb +11 -9
- data/spec/faraday/adapter/patron_spec.rb +1 -1
- data/spec/faraday/adapter/test_spec.rb +377 -0
- data/spec/faraday/connection_spec.rb +45 -0
- data/spec/faraday/deprecate_spec.rb +147 -0
- data/spec/faraday/error_spec.rb +15 -0
- data/spec/faraday/middleware_spec.rb +32 -6
- data/spec/faraday/options/proxy_options_spec.rb +7 -0
- data/spec/faraday/params_encoders/flat_spec.rb +8 -0
- data/spec/faraday/params_encoders/nested_spec.rb +8 -0
- data/spec/faraday/rack_builder_spec.rb +150 -1
- data/spec/faraday/request/authorization_spec.rb +10 -2
- data/spec/faraday/request/json_spec.rb +111 -0
- data/spec/faraday/request/url_encoded_spec.rb +13 -0
- data/spec/faraday/request_spec.rb +16 -5
- data/spec/faraday/response/json_spec.rb +119 -0
- data/spec/faraday/response/middleware_spec.rb +16 -0
- data/spec/faraday/response/raise_error_spec.rb +63 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/shared_examples/adapter.rb +2 -1
- data/spec/support/shared_examples/request_method.rb +39 -11
- metadata +157 -31
- data/UPGRADING.md +0 -55
- data/lib/faraday/adapter/em_http.rb +0 -285
- data/lib/faraday/adapter/em_http_ssl_patch.rb +0 -62
- data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +0 -69
- data/lib/faraday/adapter/em_synchrony.rb +0 -150
- data/lib/faraday/adapter/excon.rb +0 -124
- data/lib/faraday/adapter/httpclient.rb +0 -151
- data/lib/faraday/adapter/net_http.rb +0 -209
- data/lib/faraday/adapter/net_http_persistent.rb +0 -91
- data/lib/faraday/adapter/patron.rb +0 -132
- data/lib/faraday/adapter/rack.rb +0 -75
- data/lib/faraday/file_part.rb +0 -128
- data/lib/faraday/param_part.rb +0 -53
- data/lib/faraday/request/multipart.rb +0 -99
- data/lib/faraday/request/retry.rb +0 -239
- data/spec/faraday/adapter/net_http_persistent_spec.rb +0 -57
- data/spec/faraday/request/multipart_spec.rb +0 -274
- data/spec/faraday/request/retry_spec.rb +0 -242
@@ -33,6 +33,7 @@ shared_examples 'adapter examples' do |**options|
|
|
33
33
|
|
34
34
|
let(:protocol) { ssl_mode? ? 'https' : 'http' }
|
35
35
|
let(:remote) { "#{protocol}://example.com" }
|
36
|
+
let(:stub_remote) { remote }
|
36
37
|
|
37
38
|
let(:conn) do
|
38
39
|
conn_options[:ssl] ||= {}
|
@@ -46,7 +47,7 @@ shared_examples 'adapter examples' do |**options|
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
let!(:request_stub) { stub_request(http_method,
|
50
|
+
let!(:request_stub) { stub_request(http_method, stub_remote) }
|
50
51
|
|
51
52
|
after do
|
52
53
|
expect(request_stub).to have_been_requested unless request_stub.disabled?
|
@@ -1,5 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
shared_examples 'proxy examples' do
|
4
|
+
it 'handles requests with proxy' do
|
5
|
+
res = conn.public_send(http_method, '/')
|
6
|
+
|
7
|
+
expect(res.status).to eq(200)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'handles proxy failures' do
|
11
|
+
request_stub.to_return(status: 407)
|
12
|
+
|
13
|
+
expect { conn.public_send(http_method, '/') }.to raise_error(Faraday::ProxyAuthError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
3
17
|
shared_examples 'a request method' do |http_method|
|
4
18
|
let(:query_or_body) { method_with_body?(http_method) ? :body : :query }
|
5
19
|
let(:response) { conn.public_send(http_method, '/') }
|
@@ -13,8 +27,8 @@ shared_examples 'a request method' do |http_method|
|
|
13
27
|
end
|
14
28
|
|
15
29
|
it 'handles headers with multiple values' do
|
16
|
-
request_stub.to_return(headers: { 'Set-Cookie' => '
|
17
|
-
expect(response.headers['set-cookie']).to eq('
|
30
|
+
request_stub.to_return(headers: { 'Set-Cookie' => 'name=value' })
|
31
|
+
expect(response.headers['set-cookie']).to eq('name=value')
|
18
32
|
end
|
19
33
|
|
20
34
|
it 'retrieves the response headers' do
|
@@ -119,7 +133,7 @@ shared_examples 'a request method' do |http_method|
|
|
119
133
|
request_stub.with(headers: { 'Content-Type' => %r{\Amultipart/form-data} }) do |request|
|
120
134
|
# WebMock does not support matching body for multipart/form-data requests yet :(
|
121
135
|
# https://github.com/bblimke/webmock/issues/623
|
122
|
-
request.body
|
136
|
+
request.body.include?('RubyMultipartPost')
|
123
137
|
end
|
124
138
|
conn.public_send(http_method, '/', payload)
|
125
139
|
end
|
@@ -218,17 +232,31 @@ shared_examples 'a request method' do |http_method|
|
|
218
232
|
end
|
219
233
|
end
|
220
234
|
|
221
|
-
|
222
|
-
|
235
|
+
context 'when a proxy is provided as option' do
|
236
|
+
before do
|
237
|
+
conn_options[:proxy] = 'http://env-proxy.com:80'
|
238
|
+
end
|
223
239
|
|
224
|
-
|
225
|
-
expect(res.status).to eq(200)
|
240
|
+
include_examples 'proxy examples'
|
226
241
|
end
|
227
242
|
|
228
|
-
|
229
|
-
|
230
|
-
request_stub.to_return(status: 407)
|
243
|
+
context 'when http_proxy env variable is set' do
|
244
|
+
let(:proxy_url) { 'http://env-proxy.com:80' }
|
231
245
|
|
232
|
-
|
246
|
+
around do |example|
|
247
|
+
with_env 'http_proxy' => proxy_url do
|
248
|
+
example.run
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
include_examples 'proxy examples'
|
253
|
+
|
254
|
+
context 'when the env proxy is ignored' do
|
255
|
+
around do |example|
|
256
|
+
with_env_proxy_disabled(&example)
|
257
|
+
end
|
258
|
+
|
259
|
+
include_examples 'proxy examples'
|
260
|
+
end
|
233
261
|
end
|
234
262
|
end
|
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.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "@technoweenie"
|
@@ -10,28 +10,162 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: faraday-em_http
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: faraday-em_synchrony
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '1.0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: faraday-excon
|
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'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: faraday-httpclient
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.0'
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '1.0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: faraday-multipart
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.0'
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '1.0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: faraday-net_http
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.0'
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
20
97
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
22
|
-
|
98
|
+
version: '1.0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: faraday-net_http_persistent
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
23
104
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
105
|
+
version: '1.0'
|
25
106
|
type: :runtime
|
26
107
|
prerelease: false
|
27
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '1.0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: faraday-patron
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '1.0'
|
120
|
+
type: :runtime
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '1.0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: faraday-rack
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '1.0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '1.0'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: faraday-retry
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '1.0'
|
148
|
+
type: :runtime
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - "~>"
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '1.0'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: ruby2_keywords
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
28
158
|
requirements:
|
29
159
|
- - ">="
|
30
160
|
- !ruby/object:Gem::Version
|
31
|
-
version:
|
32
|
-
|
161
|
+
version: 0.0.4
|
162
|
+
type: :runtime
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
33
167
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
168
|
+
version: 0.0.4
|
35
169
|
description:
|
36
170
|
email: technoweenie@gmail.com
|
37
171
|
executables: []
|
@@ -42,32 +176,22 @@ files:
|
|
42
176
|
- LICENSE.md
|
43
177
|
- README.md
|
44
178
|
- Rakefile
|
45
|
-
- UPGRADING.md
|
46
179
|
- examples/client_spec.rb
|
47
180
|
- examples/client_test.rb
|
48
181
|
- lib/faraday.rb
|
49
182
|
- lib/faraday/adapter.rb
|
50
|
-
- lib/faraday/adapter/em_http.rb
|
51
|
-
- lib/faraday/adapter/em_http_ssl_patch.rb
|
52
|
-
- lib/faraday/adapter/em_synchrony.rb
|
53
|
-
- lib/faraday/adapter/em_synchrony/parallel_manager.rb
|
54
|
-
- lib/faraday/adapter/excon.rb
|
55
|
-
- lib/faraday/adapter/httpclient.rb
|
56
|
-
- lib/faraday/adapter/net_http.rb
|
57
|
-
- lib/faraday/adapter/net_http_persistent.rb
|
58
|
-
- lib/faraday/adapter/patron.rb
|
59
|
-
- lib/faraday/adapter/rack.rb
|
60
183
|
- lib/faraday/adapter/test.rb
|
61
184
|
- lib/faraday/adapter/typhoeus.rb
|
62
185
|
- lib/faraday/adapter_registry.rb
|
63
186
|
- lib/faraday/autoload.rb
|
64
187
|
- lib/faraday/connection.rb
|
65
188
|
- lib/faraday/dependency_loader.rb
|
189
|
+
- lib/faraday/deprecate.rb
|
66
190
|
- lib/faraday/encoders/flat_params_encoder.rb
|
67
191
|
- lib/faraday/encoders/nested_params_encoder.rb
|
68
192
|
- lib/faraday/error.rb
|
69
|
-
- lib/faraday/file_part.rb
|
70
193
|
- lib/faraday/logging/formatter.rb
|
194
|
+
- lib/faraday/methods.rb
|
71
195
|
- lib/faraday/middleware.rb
|
72
196
|
- lib/faraday/middleware_registry.rb
|
73
197
|
- lib/faraday/options.rb
|
@@ -76,37 +200,38 @@ files:
|
|
76
200
|
- lib/faraday/options/proxy_options.rb
|
77
201
|
- lib/faraday/options/request_options.rb
|
78
202
|
- lib/faraday/options/ssl_options.rb
|
79
|
-
- lib/faraday/param_part.rb
|
80
203
|
- lib/faraday/parameters.rb
|
81
204
|
- lib/faraday/rack_builder.rb
|
82
205
|
- lib/faraday/request.rb
|
83
206
|
- lib/faraday/request/authorization.rb
|
84
207
|
- lib/faraday/request/basic_authentication.rb
|
85
208
|
- lib/faraday/request/instrumentation.rb
|
86
|
-
- lib/faraday/request/
|
87
|
-
- lib/faraday/request/retry.rb
|
209
|
+
- lib/faraday/request/json.rb
|
88
210
|
- lib/faraday/request/token_authentication.rb
|
89
211
|
- lib/faraday/request/url_encoded.rb
|
90
212
|
- lib/faraday/response.rb
|
213
|
+
- lib/faraday/response/json.rb
|
91
214
|
- lib/faraday/response/logger.rb
|
92
215
|
- lib/faraday/response/raise_error.rb
|
93
216
|
- lib/faraday/utils.rb
|
94
217
|
- lib/faraday/utils/headers.rb
|
95
218
|
- lib/faraday/utils/params_hash.rb
|
219
|
+
- lib/faraday/version.rb
|
96
220
|
- spec/external_adapters/faraday_specs_setup.rb
|
97
221
|
- spec/faraday/adapter/em_http_spec.rb
|
98
222
|
- spec/faraday/adapter/em_synchrony_spec.rb
|
99
223
|
- spec/faraday/adapter/excon_spec.rb
|
100
224
|
- spec/faraday/adapter/httpclient_spec.rb
|
101
|
-
- spec/faraday/adapter/net_http_persistent_spec.rb
|
102
225
|
- spec/faraday/adapter/net_http_spec.rb
|
103
226
|
- spec/faraday/adapter/patron_spec.rb
|
104
227
|
- spec/faraday/adapter/rack_spec.rb
|
228
|
+
- spec/faraday/adapter/test_spec.rb
|
105
229
|
- spec/faraday/adapter/typhoeus_spec.rb
|
106
230
|
- spec/faraday/adapter_registry_spec.rb
|
107
231
|
- spec/faraday/adapter_spec.rb
|
108
232
|
- spec/faraday/composite_read_io_spec.rb
|
109
233
|
- spec/faraday/connection_spec.rb
|
234
|
+
- spec/faraday/deprecate_spec.rb
|
110
235
|
- spec/faraday/error_spec.rb
|
111
236
|
- spec/faraday/middleware_spec.rb
|
112
237
|
- spec/faraday/options/env_spec.rb
|
@@ -118,10 +243,10 @@ files:
|
|
118
243
|
- spec/faraday/rack_builder_spec.rb
|
119
244
|
- spec/faraday/request/authorization_spec.rb
|
120
245
|
- spec/faraday/request/instrumentation_spec.rb
|
121
|
-
- spec/faraday/request/
|
122
|
-
- spec/faraday/request/retry_spec.rb
|
246
|
+
- spec/faraday/request/json_spec.rb
|
123
247
|
- spec/faraday/request/url_encoded_spec.rb
|
124
248
|
- spec/faraday/request_spec.rb
|
249
|
+
- spec/faraday/response/json_spec.rb
|
125
250
|
- spec/faraday/response/logger_spec.rb
|
126
251
|
- spec/faraday/response/middleware_spec.rb
|
127
252
|
- spec/faraday/response/raise_error_spec.rb
|
@@ -143,25 +268,26 @@ licenses:
|
|
143
268
|
- MIT
|
144
269
|
metadata:
|
145
270
|
homepage_uri: https://lostisland.github.io/faraday
|
146
|
-
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v1.
|
271
|
+
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v1.10.3
|
147
272
|
source_code_uri: https://github.com/lostisland/faraday
|
148
273
|
bug_tracker_uri: https://github.com/lostisland/faraday/issues
|
149
274
|
post_install_message:
|
150
275
|
rdoc_options: []
|
151
276
|
require_paths:
|
152
277
|
- lib
|
278
|
+
- spec/external_adapters
|
153
279
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
280
|
requirements:
|
155
281
|
- - ">="
|
156
282
|
- !ruby/object:Gem::Version
|
157
|
-
version: '2.
|
283
|
+
version: '2.4'
|
158
284
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
285
|
requirements:
|
160
286
|
- - ">="
|
161
287
|
- !ruby/object:Gem::Version
|
162
288
|
version: '0'
|
163
289
|
requirements: []
|
164
|
-
rubygems_version: 3.1.
|
290
|
+
rubygems_version: 3.1.6
|
165
291
|
signing_key:
|
166
292
|
specification_version: 4
|
167
293
|
summary: HTTP/REST API client library.
|
data/UPGRADING.md
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
## Faraday 1.0
|
2
|
-
|
3
|
-
### Errors
|
4
|
-
* Removes sub-class constants definition from `Faraday::Error`. A sub-class (e.g. `ClientError`) was previously accessible
|
5
|
-
either through the `Faraday` module (e.g. `Faraday::ClientError`) or through the `Faraday::Error` class (e.g. `Faraday::Error::ClientError`).
|
6
|
-
The latter is no longer available and the former should be used instead, so check your `rescue`s.
|
7
|
-
* Introduces a new `Faraday::ServerError` (5xx status codes) alongside the existing `Faraday::ClientError` (4xx status codes).
|
8
|
-
Please note `Faraday::ClientError` was previously used for both.
|
9
|
-
* Introduces new Errors that describe the most common REST status codes:
|
10
|
-
* Faraday::BadRequestError (400)
|
11
|
-
* Faraday::UnauthorizedError (401)
|
12
|
-
* Faraday::ForbiddenError (403)
|
13
|
-
* Faraday::ProxyAuthError (407). Please note this raised a `Faraday::ConnectionFailed` before.
|
14
|
-
* Faraday::ConflictError (409)
|
15
|
-
* Faraday::UnprocessableEntityError (422)
|
16
|
-
* The following error classes have changed the hierarchy to better mirror their real-world usage and semantic meaning:
|
17
|
-
* TimeoutError < ServerError (was < ClientError)
|
18
|
-
* ConnectionFailed < Error (was < ClientError)
|
19
|
-
* SSLError < Error (was < ClientError)
|
20
|
-
* ParsingError < Error (was < ClientError)
|
21
|
-
* RetriableResponse < Error (was < ClientError)
|
22
|
-
|
23
|
-
### Custom adapters
|
24
|
-
If you have written a custom adapter, please be aware that `env.body` is now an alias to the two new properties `request_body` and `response_body`.
|
25
|
-
This should work without you noticing if your adapter inherits from `Faraday::Adapter` and calls `save_response`, but if it doesn't, then please ensure you set the `status` BEFORE the `body` while processing the response.
|
26
|
-
|
27
|
-
### Others
|
28
|
-
* Dropped support for jruby and Rubinius.
|
29
|
-
* Officially supports Ruby 2.4+
|
30
|
-
* In order to specify the adapter you now MUST use the `#adapter` method on the connection builder. If you don't do so and your adapter inherits from `Faraday::Adapter` then Faraday will raise an exception. Otherwise, Faraday will automatically push the default adapter at the end of the stack causing your request to be executed twice.
|
31
|
-
```ruby
|
32
|
-
class OfficialAdapter < Faraday::Adapter
|
33
|
-
...
|
34
|
-
end
|
35
|
-
|
36
|
-
class MyAdapter
|
37
|
-
...
|
38
|
-
end
|
39
|
-
|
40
|
-
# This will raise an exception
|
41
|
-
conn = Faraday.new(...) do |f|
|
42
|
-
f.use OfficialAdapter
|
43
|
-
end
|
44
|
-
|
45
|
-
# This will cause Faraday inserting the default adapter at the end of the stack
|
46
|
-
conn = Faraday.new(...) do |f|
|
47
|
-
f.use MyAdapter
|
48
|
-
end
|
49
|
-
|
50
|
-
# You MUST use `adapter` method
|
51
|
-
conn = Faraday.new(...) do |f|
|
52
|
-
f.adapter AnyAdapter
|
53
|
-
end
|
54
|
-
```
|
55
|
-
|