faraday 1.2.0 → 1.4.2
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/README.md +1 -2
- data/lib/faraday.rb +7 -1
- data/lib/faraday/adapter.rb +0 -8
- data/lib/faraday/autoload.rb +0 -5
- data/lib/faraday/connection.rb +8 -1
- data/lib/faraday/error.rb +12 -0
- data/lib/faraday/options/proxy_options.rb +4 -0
- data/lib/faraday/request/retry.rb +1 -1
- data/lib/faraday/version.rb +1 -1
- data/spec/faraday/connection_spec.rb +38 -0
- data/spec/faraday/error_spec.rb +15 -0
- data/spec/faraday/options/proxy_options_spec.rb +7 -0
- data/spec/faraday/response/raise_error_spec.rb +30 -0
- metadata +76 -14
- data/lib/faraday/adapter/em_http.rb +0 -289
- data/lib/faraday/adapter/em_http_ssl_patch.rb +0 -62
- data/lib/faraday/adapter/em_synchrony.rb +0 -153
- data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +0 -69
- data/lib/faraday/adapter/excon.rb +0 -124
- data/lib/faraday/adapter/net_http.rb +0 -220
- 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: 5b0077d079fbfe478a57bbc4f804b9e8761addcad6266587434f99534d9ca935
|
4
|
+
data.tar.gz: 465fc3bb1ad67259f4e6515ff3ea006c833d4dca43946cb79da683311eccf4e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63deab2286691410961536ed63f36a5d23917227327e2ccfbc919621ba86dae8e397e8fbe3b29826a309e988a8924a8943583ac42b515aa07dd6dccacdc323a2
|
7
|
+
data.tar.gz: 5827629437871707807bcfc405f02bc6a9a19fc99cc655bb44de37fbc4aaa5c277dd29895153cb506e0718d841229c6086ef00314c262ebda7e2ac68b5f90ce6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,109 @@
|
|
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
|
+
|
33
|
+
## [v1.2.0](https://github.com/lostisland/faraday/releases/tag/v1.2.0) (2020-12-23)
|
34
|
+
|
35
|
+
### Features
|
36
|
+
|
37
|
+
* Introduces `on_request` and `on_complete` methods in `Faraday::Middleware`. (#1194, @iMacTia)
|
38
|
+
|
39
|
+
### Fixes
|
40
|
+
|
41
|
+
* Require 'date' to avoid retry exception (#1206, @rustygeldmacher)
|
42
|
+
* Fix rdebug recursion issue (#1205, @native-api)
|
43
|
+
* Update call to `em_http_ssl_patch` (#1202, @kylekeesling)
|
44
|
+
* `EmHttp` adapter: drop superfluous loaded? check (#1213, @olleolleolle)
|
45
|
+
* Avoid 1 use of keyword hackery (#1211, @grosser)
|
46
|
+
* Fix #1219 `Net::HTTP` still uses env proxy (#1221, @iMacTia)
|
47
|
+
|
48
|
+
### Documentation
|
49
|
+
|
50
|
+
* Add comment in gemspec to explain exposure of `examples` and `spec` folders. (#1192, @iMacTia)
|
51
|
+
* Adapters, how to create them (#1193, @olleolleolle)
|
52
|
+
* Update documentation on using the logger (#1196, @tijmenb)
|
53
|
+
* Adjust the retry documentation and spec to align with implementation (#1198, @nbeyer)
|
54
|
+
|
55
|
+
### Misc
|
56
|
+
|
57
|
+
* Test against ruby head (#1208, @grosser)
|
58
|
+
|
59
|
+
## [v1.1.0](https://github.com/lostisland/faraday/releases/tag/v1.1.0) (2020-10-17)
|
60
|
+
|
61
|
+
### Features
|
62
|
+
|
63
|
+
* Makes parameters sorting configurable (#1162 @wishdev)
|
64
|
+
* Introduces `flat_encode` option for multipart adapter. (#1163 @iMacTia)
|
65
|
+
* Include request info in exceptions raised by RaiseError Middleware (#1181 @SandroDamilano)
|
66
|
+
|
67
|
+
### Fixes
|
68
|
+
|
69
|
+
* Avoid `last arg as keyword param` warning when building user middleware on Ruby 2.7 (#1153 @dgholz)
|
70
|
+
* Limits net-http-persistent version to < 4.0 (#1156 @iMacTia)
|
71
|
+
* Update `typhoeus` to new stable version (`1.4`) (#1159 @AlexWayfer)
|
72
|
+
* Properly fix test failure with Rack 2.1+. (#1171 @voxik)
|
73
|
+
|
74
|
+
### Documentation
|
75
|
+
|
76
|
+
* Improves documentation on how to contribute to the site by using Docker. (#1175 @iMacTia)
|
77
|
+
* Remove retry_change_requests from documentation (#1185 @stim371)
|
78
|
+
|
79
|
+
### Misc
|
80
|
+
|
81
|
+
* Link from GitHub Actions badge to CI workflow (#1141 @olleolleolle)
|
82
|
+
* Return tests of `Test` adapter (#1147 @AlexWayfer)
|
83
|
+
* Add 1.0 release to wording in CONTRIBUTING (#1155 @olleolleolle)
|
84
|
+
* Fix linting bumping Rubocop to 0.90.0 (#1182 @iMacTia)
|
85
|
+
* Drop `git ls-files` in gemspec (#1183 @utkarsh2102)
|
86
|
+
* Upgrade CI to ruby/setup-ruby (#1187 @gogainda)
|
87
|
+
|
88
|
+
## [v1.0.1](https://github.com/lostisland/faraday/releases/tag/v1.0.1) (2020-03-29)
|
89
|
+
|
90
|
+
### Fixes
|
91
|
+
|
92
|
+
* Use Net::HTTP#start(&block) to ensure closed TCP connections (#1117)
|
93
|
+
* Fully qualify constants to be checked (#1122)
|
94
|
+
* Allows `parse` method to be private/protected in response middleware (#1123)
|
95
|
+
* Encode Spaces in Query Strings as '%20' Instead of '+' (#1125)
|
96
|
+
* Limits rack to v2.0.x (#1127)
|
97
|
+
* Adapter Registry reads also use mutex (#1136)
|
98
|
+
|
99
|
+
### Documentation
|
100
|
+
|
101
|
+
* Retry middleware documentation fix (#1109)
|
102
|
+
* Docs(retry): precise usage of retry-after (#1111)
|
103
|
+
* README: Link the logo to the website (#1112)
|
104
|
+
* Website: add search bar (#1116)
|
105
|
+
* Fix request/response mix-up in docs text (#1132)
|
106
|
+
|
3
107
|
## v1.0
|
4
108
|
|
5
109
|
Features:
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/faraday.svg)](https://rubygems.org/gems/faraday)
|
4
4
|
[![GitHub Actions CI](https://github.com/lostisland/faraday/workflows/CI/badge.svg)](https://github.com/lostisland/faraday/actions?query=workflow%3ACI)
|
5
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/f869daab091ceef1da73/maintainability)](https://codeclimate.com/github/lostisland/faraday/maintainability)
|
6
5
|
[![Gitter](https://badges.gitter.im/lostisland/faraday.svg)](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
@@ -9,7 +9,7 @@ require 'faraday/dependency_loader'
|
|
9
9
|
|
10
10
|
unless defined?(::Faraday::Timer)
|
11
11
|
require 'timeout'
|
12
|
-
Timer = Timeout
|
12
|
+
::Faraday::Timer = Timeout
|
13
13
|
end
|
14
14
|
|
15
15
|
require 'faraday/version'
|
@@ -27,6 +27,12 @@ require 'faraday/error'
|
|
27
27
|
require 'faraday/file_part'
|
28
28
|
require 'faraday/param_part'
|
29
29
|
|
30
|
+
require 'faraday/em_http'
|
31
|
+
require 'faraday/em_synchrony'
|
32
|
+
require 'faraday/excon'
|
33
|
+
require 'faraday/net_http'
|
34
|
+
require 'faraday/net_http_persistent'
|
35
|
+
|
30
36
|
# This is the main namespace for Faraday.
|
31
37
|
#
|
32
38
|
# It provides methods to create {Connection} objects, and HTTP-related
|
data/lib/faraday/adapter.rb
CHANGED
@@ -11,16 +11,8 @@ module Faraday
|
|
11
11
|
|
12
12
|
register_middleware File.expand_path('adapter', __dir__),
|
13
13
|
test: [:Test, 'test'],
|
14
|
-
net_http: [:NetHttp, 'net_http'],
|
15
|
-
net_http_persistent: [
|
16
|
-
:NetHttpPersistent,
|
17
|
-
'net_http_persistent'
|
18
|
-
],
|
19
14
|
typhoeus: [:Typhoeus, 'typhoeus'],
|
20
15
|
patron: [:Patron, 'patron'],
|
21
|
-
em_synchrony: [:EMSynchrony, 'em_synchrony'],
|
22
|
-
em_http: [:EMHttp, 'em_http'],
|
23
|
-
excon: [:Excon, 'excon'],
|
24
16
|
rack: [:Rack, 'rack'],
|
25
17
|
httpclient: [:HTTPClient, 'httpclient']
|
26
18
|
|
data/lib/faraday/autoload.rb
CHANGED
@@ -58,13 +58,8 @@ module Faraday
|
|
58
58
|
class Adapter
|
59
59
|
extend AutoloadHelper
|
60
60
|
autoload_all 'faraday/adapter',
|
61
|
-
NetHttp: 'net_http',
|
62
|
-
NetHttpPersistent: 'net_http_persistent',
|
63
|
-
EMSynchrony: 'em_synchrony',
|
64
|
-
EMHttp: 'em_http',
|
65
61
|
Typhoeus: 'typhoeus',
|
66
62
|
Patron: 'patron',
|
67
|
-
Excon: 'excon',
|
68
63
|
Test: 'test',
|
69
64
|
Rack: 'rack',
|
70
65
|
HTTPClient: 'httpclient'
|
data/lib/faraday/connection.rb
CHANGED
@@ -419,6 +419,8 @@ module Faraday
|
|
419
419
|
basic_auth user, password
|
420
420
|
uri.user = uri.password = nil
|
421
421
|
end
|
422
|
+
|
423
|
+
@proxy = proxy_from_env(url) unless @manual_proxy
|
422
424
|
end
|
423
425
|
|
424
426
|
# Sets the path prefix and ensures that it always has a leading
|
@@ -522,6 +524,7 @@ module Faraday
|
|
522
524
|
base = base.dup
|
523
525
|
base.path = "#{base.path}/" # ensure trailing slash
|
524
526
|
end
|
527
|
+
url = url && URI.parse(url.to_s).opaque ? url.to_s.gsub(':', '%3A') : url
|
525
528
|
uri = url ? base + url : base
|
526
529
|
if params
|
527
530
|
uri.query = params.to_query(params_encoder || options.params_encoder)
|
@@ -576,7 +579,11 @@ module Faraday
|
|
576
579
|
case url
|
577
580
|
when String
|
578
581
|
uri = Utils.URI(url)
|
579
|
-
uri =
|
582
|
+
uri = if uri.host.nil?
|
583
|
+
find_default_proxy
|
584
|
+
else
|
585
|
+
URI.parse("#{uri.scheme}://#{uri.host}").find_proxy
|
586
|
+
end
|
580
587
|
when URI
|
581
588
|
uri = url.find_proxy
|
582
589
|
when nil
|
data/lib/faraday/error.rb
CHANGED
@@ -28,6 +28,18 @@ module Faraday
|
|
28
28
|
%(#<#{self.class}#{inner}>)
|
29
29
|
end
|
30
30
|
|
31
|
+
def response_status
|
32
|
+
@response[:status] if @response
|
33
|
+
end
|
34
|
+
|
35
|
+
def response_headers
|
36
|
+
@response[:headers] if @response
|
37
|
+
end
|
38
|
+
|
39
|
+
def response_body
|
40
|
+
@response[:body] if @response
|
41
|
+
end
|
42
|
+
|
31
43
|
protected
|
32
44
|
|
33
45
|
# Pulls out potential parent exception and response hash, storing them in
|
@@ -11,6 +11,9 @@ module Faraday
|
|
11
11
|
def self.from(value)
|
12
12
|
case value
|
13
13
|
when String
|
14
|
+
# URIs without a scheme should default to http (like 'example:123').
|
15
|
+
# This fixes #1282 and prevents a silent failure in some adapters.
|
16
|
+
value = "http://#{value}" unless value.include?('://')
|
14
17
|
value = { uri: Utils.URI(value) }
|
15
18
|
when URI
|
16
19
|
value = { uri: value }
|
@@ -19,6 +22,7 @@ module Faraday
|
|
19
22
|
value[:uri] = Utils.URI(uri)
|
20
23
|
end
|
21
24
|
end
|
25
|
+
|
22
26
|
super(value)
|
23
27
|
end
|
24
28
|
|
@@ -112,7 +112,7 @@ module Faraday
|
|
112
112
|
# not independent of the retry count. This would be useful
|
113
113
|
# if the exception produced is non-recoverable or if the
|
114
114
|
# the HTTP method called is not idempotent.
|
115
|
-
# @option options [Block] :retry_block block that is executed
|
115
|
+
# @option options [Block] :retry_block block that is executed before
|
116
116
|
# every retry. Request environment, middleware options, current number
|
117
117
|
# of retries and the exception is passed to the block as parameters.
|
118
118
|
# @option options [Array] :retry_statuses Array of Integer HTTP status
|
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
|
@@ -412,6 +442,14 @@ RSpec.describe Faraday::Connection do
|
|
412
442
|
end
|
413
443
|
end
|
414
444
|
|
445
|
+
it 'allows when url in no proxy list with url_prefix' do
|
446
|
+
with_env 'http_proxy' => 'http://proxy.com', 'no_proxy' => 'example.com' do
|
447
|
+
conn = Faraday::Connection.new
|
448
|
+
conn.url_prefix = 'http://example.com'
|
449
|
+
expect(conn.proxy).to be_nil
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
415
453
|
it 'allows when prefixed url is not in no proxy list' do
|
416
454
|
with_env 'http_proxy' => 'http://proxy.com', 'no_proxy' => 'example.com' do
|
417
455
|
conn = Faraday::Connection.new('http://prefixedexample.com')
|
data/spec/faraday/error_spec.rb
CHANGED
@@ -13,6 +13,7 @@ RSpec.describe Faraday::ClientError do
|
|
13
13
|
it { expect(subject.message).to eq(exception.message) }
|
14
14
|
it { expect(subject.backtrace).to eq(exception.backtrace) }
|
15
15
|
it { expect(subject.inspect).to eq('#<Faraday::ClientError wrapped=#<RuntimeError: test>>') }
|
16
|
+
it { expect(subject.response_status).to be_nil }
|
16
17
|
end
|
17
18
|
|
18
19
|
context 'with response hash' do
|
@@ -22,6 +23,7 @@ RSpec.describe Faraday::ClientError do
|
|
22
23
|
it { expect(subject.response).to eq(exception) }
|
23
24
|
it { expect(subject.message).to eq('the server responded with status 400') }
|
24
25
|
it { expect(subject.inspect).to eq('#<Faraday::ClientError response={:status=>400}>') }
|
26
|
+
it { expect(subject.response_status).to eq(400) }
|
25
27
|
end
|
26
28
|
|
27
29
|
context 'with string' do
|
@@ -31,6 +33,7 @@ RSpec.describe Faraday::ClientError do
|
|
31
33
|
it { expect(subject.response).to be_nil }
|
32
34
|
it { expect(subject.message).to eq('custom message') }
|
33
35
|
it { expect(subject.inspect).to eq('#<Faraday::ClientError #<Faraday::ClientError: custom message>>') }
|
36
|
+
it { expect(subject.response_status).to be_nil }
|
34
37
|
end
|
35
38
|
|
36
39
|
context 'with anything else #to_s' do
|
@@ -40,6 +43,18 @@ RSpec.describe Faraday::ClientError do
|
|
40
43
|
it { expect(subject.response).to be_nil }
|
41
44
|
it { expect(subject.message).to eq('["error1", "error2"]') }
|
42
45
|
it { expect(subject.inspect).to eq('#<Faraday::ClientError #<Faraday::ClientError: ["error1", "error2"]>>') }
|
46
|
+
it { expect(subject.response_status).to be_nil }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with exception string and response hash' do
|
50
|
+
let(:exception) { 'custom message' }
|
51
|
+
let(:response) { { status: 400 } }
|
52
|
+
|
53
|
+
it { expect(subject.wrapped_exception).to be_nil }
|
54
|
+
it { expect(subject.response).to eq(response) }
|
55
|
+
it { expect(subject.message).to eq('custom message') }
|
56
|
+
it { expect(subject.inspect).to eq('#<Faraday::ClientError response={:status=>400}>') }
|
57
|
+
it { expect(subject.response_status).to eq(400) }
|
43
58
|
end
|
44
59
|
end
|
45
60
|
end
|
@@ -14,6 +14,13 @@ RSpec.describe Faraday::ProxyOptions do
|
|
14
14
|
expect(options.inspect).to match('#<Faraday::ProxyOptions uri=')
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'defaults to http' do
|
18
|
+
options = Faraday::ProxyOptions.from 'example.org'
|
19
|
+
expect(options.port).to eq(80)
|
20
|
+
expect(options.host).to eq('example.org')
|
21
|
+
expect(options.scheme).to eq('http')
|
22
|
+
end
|
23
|
+
|
17
24
|
it 'works with nil' do
|
18
25
|
options = Faraday::ProxyOptions.from nil
|
19
26
|
expect(options).to be_a_kind_of(Faraday::ProxyOptions)
|
@@ -29,6 +29,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
29
29
|
expect(ex.message).to eq('the server responded with status 400')
|
30
30
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
31
31
|
expect(ex.response[:status]).to eq(400)
|
32
|
+
expect(ex.response_status).to eq(400)
|
33
|
+
expect(ex.response_body).to eq('keep looking')
|
34
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
@@ -37,6 +40,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
37
40
|
expect(ex.message).to eq('the server responded with status 401')
|
38
41
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
39
42
|
expect(ex.response[:status]).to eq(401)
|
43
|
+
expect(ex.response_status).to eq(401)
|
44
|
+
expect(ex.response_body).to eq('keep looking')
|
45
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
@@ -45,6 +51,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
45
51
|
expect(ex.message).to eq('the server responded with status 403')
|
46
52
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
47
53
|
expect(ex.response[:status]).to eq(403)
|
54
|
+
expect(ex.response_status).to eq(403)
|
55
|
+
expect(ex.response_body).to eq('keep looking')
|
56
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
@@ -53,6 +62,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
53
62
|
expect(ex.message).to eq('the server responded with status 404')
|
54
63
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
55
64
|
expect(ex.response[:status]).to eq(404)
|
65
|
+
expect(ex.response_status).to eq(404)
|
66
|
+
expect(ex.response_body).to eq('keep looking')
|
67
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
56
68
|
end
|
57
69
|
end
|
58
70
|
|
@@ -61,6 +73,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
61
73
|
expect(ex.message).to eq('407 "Proxy Authentication Required"')
|
62
74
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
63
75
|
expect(ex.response[:status]).to eq(407)
|
76
|
+
expect(ex.response_status).to eq(407)
|
77
|
+
expect(ex.response_body).to eq('keep looking')
|
78
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
64
79
|
end
|
65
80
|
end
|
66
81
|
|
@@ -69,6 +84,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
69
84
|
expect(ex.message).to eq('the server responded with status 409')
|
70
85
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
71
86
|
expect(ex.response[:status]).to eq(409)
|
87
|
+
expect(ex.response_status).to eq(409)
|
88
|
+
expect(ex.response_body).to eq('keep looking')
|
89
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
72
90
|
end
|
73
91
|
end
|
74
92
|
|
@@ -77,6 +95,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
77
95
|
expect(ex.message).to eq('the server responded with status 422')
|
78
96
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
79
97
|
expect(ex.response[:status]).to eq(422)
|
98
|
+
expect(ex.response_status).to eq(422)
|
99
|
+
expect(ex.response_body).to eq('keep looking')
|
100
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
80
101
|
end
|
81
102
|
end
|
82
103
|
|
@@ -85,6 +106,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
85
106
|
expect(ex.message).to eq('http status could not be derived from the server response')
|
86
107
|
expect(ex.response[:headers]['X-Reason']).to eq('nil')
|
87
108
|
expect(ex.response[:status]).to be_nil
|
109
|
+
expect(ex.response_status).to be_nil
|
110
|
+
expect(ex.response_body).to eq('fail')
|
111
|
+
expect(ex.response_headers['X-Reason']).to eq('nil')
|
88
112
|
end
|
89
113
|
end
|
90
114
|
|
@@ -93,6 +117,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
93
117
|
expect(ex.message).to eq('the server responded with status 499')
|
94
118
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
95
119
|
expect(ex.response[:status]).to eq(499)
|
120
|
+
expect(ex.response_status).to eq(499)
|
121
|
+
expect(ex.response_body).to eq('keep looking')
|
122
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
96
123
|
end
|
97
124
|
end
|
98
125
|
|
@@ -101,6 +128,9 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
101
128
|
expect(ex.message).to eq('the server responded with status 500')
|
102
129
|
expect(ex.response[:headers]['X-Error']).to eq('bailout')
|
103
130
|
expect(ex.response[:status]).to eq(500)
|
131
|
+
expect(ex.response_status).to eq(500)
|
132
|
+
expect(ex.response_body).to eq('fail')
|
133
|
+
expect(ex.response_headers['X-Error']).to eq('bailout')
|
104
134
|
end
|
105
135
|
end
|
106
136
|
|