faraday 2.13.4 → 2.14.2
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/examples/client_test.rb +1 -1
- data/lib/faraday/adapter.rb +7 -6
- data/lib/faraday/connection.rb +5 -2
- data/lib/faraday/encoders/flat_params_encoder.rb +3 -2
- data/lib/faraday/encoders/nested_params_encoder.rb +1 -0
- data/lib/faraday/error.rb +5 -2
- data/lib/faraday/logging/formatter.rb +1 -1
- data/lib/faraday/middleware.rb +1 -1
- data/lib/faraday/options/env.rb +3 -3
- data/lib/faraday/options/proxy_options.rb +2 -1
- data/lib/faraday/options/request_options.rb +1 -1
- data/lib/faraday/options.rb +1 -1
- data/lib/faraday/rack_builder.rb +5 -5
- data/lib/faraday/response/raise_error.rb +1 -1
- data/lib/faraday/response.rb +7 -3
- data/lib/faraday/utils/headers.rb +5 -5
- data/lib/faraday/version.rb +1 -1
- data/spec/faraday/connection_spec.rb +40 -0
- data/spec/faraday/middleware_spec.rb +2 -2
- data/spec/faraday/request_spec.rb +9 -0
- data/spec/faraday/response/json_spec.rb +1 -1
- data/spec/faraday/response/logger_spec.rb +7 -1
- data/spec/faraday/response/raise_error_spec.rb +15 -4
- data/spec/faraday/response_spec.rb +7 -0
- data/spec/faraday/utils_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 05f10cf15f3eb3f35b39edc67e14c374306d286f7b282ce86e131cab66ef9726
|
|
4
|
+
data.tar.gz: 17df5c4c9c054080f80038a1d8c6e1eaf88fd5d319c5ca1f04b10bc7bc0fe350
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 511bc21e7d0e4c4ecf866f84b434e6f38d6c4eada9d17148f25db9c6cf3194c4fe6fe600cc1b41d288e611e8dbfcbbbb5e2d711051a4340239741bb9dae54b73
|
|
7
|
+
data.tar.gz: e527f43b558124d58d4c4826dc46d0716a6689fec48dea4daf47a3943e1cae5c3612b2e490c956811d0d2ba501290548e85f2b0879bd924fd026566a2dc6056e
|
data/examples/client_test.rb
CHANGED
|
@@ -26,7 +26,7 @@ class Client
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# Example API client test
|
|
29
|
-
class ClientTest < Test::Unit::TestCase
|
|
29
|
+
class ClientTest < Test::Unit::TestCase # rubocop:disable Style/OneClassPerFile
|
|
30
30
|
def test_httpbingo_name
|
|
31
31
|
stubs = Faraday::Adapter::Test::Stubs.new
|
|
32
32
|
stubs.get('/api') do |env|
|
data/lib/faraday/adapter.rb
CHANGED
|
@@ -8,6 +8,12 @@ module Faraday
|
|
|
8
8
|
|
|
9
9
|
CONTENT_LENGTH = 'Content-Length'
|
|
10
10
|
|
|
11
|
+
TIMEOUT_KEYS = {
|
|
12
|
+
read: :read_timeout,
|
|
13
|
+
open: :open_timeout,
|
|
14
|
+
write: :write_timeout
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
11
17
|
# This module marks an Adapter as supporting parallel requests.
|
|
12
18
|
module Parallelism
|
|
13
19
|
attr_writer :supports_parallel
|
|
@@ -23,6 +29,7 @@ module Faraday
|
|
|
23
29
|
end
|
|
24
30
|
|
|
25
31
|
extend Parallelism
|
|
32
|
+
|
|
26
33
|
self.supports_parallel = false
|
|
27
34
|
|
|
28
35
|
def initialize(_app = nil, opts = {}, &block)
|
|
@@ -89,12 +96,6 @@ module Faraday
|
|
|
89
96
|
end
|
|
90
97
|
options[key] || options[:timeout]
|
|
91
98
|
end
|
|
92
|
-
|
|
93
|
-
TIMEOUT_KEYS = {
|
|
94
|
-
read: :read_timeout,
|
|
95
|
-
open: :open_timeout,
|
|
96
|
-
write: :write_timeout
|
|
97
|
-
}.freeze
|
|
98
99
|
end
|
|
99
100
|
end
|
|
100
101
|
|
data/lib/faraday/connection.rb
CHANGED
|
@@ -481,8 +481,11 @@ module Faraday
|
|
|
481
481
|
if url && !base.path.end_with?('/')
|
|
482
482
|
base.path = "#{base.path}/" # ensure trailing slash
|
|
483
483
|
end
|
|
484
|
-
|
|
485
|
-
|
|
484
|
+
url = url.to_s if url.respond_to?(:host)
|
|
485
|
+
# Ensure relative url will be parsed correctly (such as `service:search` or `//evil.com`)
|
|
486
|
+
url = "./#{url}" if url.respond_to?(:start_with?) &&
|
|
487
|
+
(url.start_with?('//') ||
|
|
488
|
+
!url.start_with?('http://', 'https://', '/', './', '../'))
|
|
486
489
|
uri = url ? base + url : base
|
|
487
490
|
if params
|
|
488
491
|
uri.query = params.to_query(params_encoder || options.params_encoder)
|
|
@@ -6,6 +6,7 @@ module Faraday
|
|
|
6
6
|
module FlatParamsEncoder
|
|
7
7
|
class << self
|
|
8
8
|
extend Forwardable
|
|
9
|
+
|
|
9
10
|
def_delegators :'Faraday::Utils', :escape, :unescape
|
|
10
11
|
end
|
|
11
12
|
|
|
@@ -76,9 +77,9 @@ module Faraday
|
|
|
76
77
|
|
|
77
78
|
empty_accumulator = {}
|
|
78
79
|
|
|
79
|
-
split_query =
|
|
80
|
+
split_query = query.split('&').filter_map do |pair|
|
|
80
81
|
pair.split('=', 2) if pair && !pair.empty?
|
|
81
|
-
end
|
|
82
|
+
end
|
|
82
83
|
split_query.each_with_object(empty_accumulator.dup) do |pair, accu|
|
|
83
84
|
pair[0] = unescape(pair[0])
|
|
84
85
|
pair[1] = true if pair[1].nil?
|
data/lib/faraday/error.rb
CHANGED
|
@@ -155,9 +155,12 @@ module Faraday
|
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
# Raised by Faraday::Response::RaiseError in case of a 422 response.
|
|
158
|
-
class
|
|
158
|
+
class UnprocessableContentError < ClientError
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
+
# Used to provide compatibility with legacy error name.
|
|
162
|
+
UnprocessableEntityError = UnprocessableContentError
|
|
163
|
+
|
|
161
164
|
# Raised by Faraday::Response::RaiseError in case of a 429 response.
|
|
162
165
|
class TooManyRequestsError < ClientError
|
|
163
166
|
end
|
|
@@ -169,7 +172,7 @@ module Faraday
|
|
|
169
172
|
# A unified client error for timeouts.
|
|
170
173
|
class TimeoutError < ServerError
|
|
171
174
|
def initialize(exc = 'timeout', response = nil)
|
|
172
|
-
super
|
|
175
|
+
super
|
|
173
176
|
end
|
|
174
177
|
end
|
|
175
178
|
|
data/lib/faraday/middleware.rb
CHANGED
data/lib/faraday/options/env.rb
CHANGED
|
@@ -78,7 +78,7 @@ module Faraday
|
|
|
78
78
|
# @param value [Object] a value fitting Option.from(v).
|
|
79
79
|
# @return [Env] from given value
|
|
80
80
|
def self.from(value)
|
|
81
|
-
env = super
|
|
81
|
+
env = super
|
|
82
82
|
if value.respond_to?(:custom_members)
|
|
83
83
|
env.custom_members.update(value.custom_members)
|
|
84
84
|
end
|
|
@@ -90,7 +90,7 @@ module Faraday
|
|
|
90
90
|
return self[current_body] if key == :body
|
|
91
91
|
|
|
92
92
|
if in_member_set?(key)
|
|
93
|
-
super
|
|
93
|
+
super
|
|
94
94
|
else
|
|
95
95
|
custom_members[key]
|
|
96
96
|
end
|
|
@@ -105,7 +105,7 @@ module Faraday
|
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
if in_member_set?(key)
|
|
108
|
-
super
|
|
108
|
+
super
|
|
109
109
|
else
|
|
110
110
|
custom_members[key] = value
|
|
111
111
|
end
|
|
@@ -7,6 +7,7 @@ module Faraday
|
|
|
7
7
|
# class ProxyOptions < Options; end
|
|
8
8
|
ProxyOptions = Options.new(:uri, :user, :password) do
|
|
9
9
|
extend Forwardable
|
|
10
|
+
|
|
10
11
|
def_delegators :uri, :scheme, :scheme=, :host, :host=, :port, :port=,
|
|
11
12
|
:path, :path=
|
|
12
13
|
|
|
@@ -29,7 +30,7 @@ module Faraday
|
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
super
|
|
33
|
+
super
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
memoized(:user) { uri&.user && Utils.unescape(uri.user) }
|
data/lib/faraday/options.rb
CHANGED
data/lib/faraday/rack_builder.rb
CHANGED
|
@@ -15,6 +15,11 @@ module Faraday
|
|
|
15
15
|
# Used to detect missing arguments
|
|
16
16
|
NO_ARGUMENT = Object.new
|
|
17
17
|
|
|
18
|
+
LOCK_ERR = "can't modify middleware stack after making a request"
|
|
19
|
+
MISSING_ADAPTER_ERROR = "An attempt to run a request with a Faraday::Connection without adapter has been made.\n" \
|
|
20
|
+
"Please set Faraday.default_adapter or provide one when initializing the connection.\n" \
|
|
21
|
+
'For more info, check https://lostisland.github.io/faraday/usage/.'
|
|
22
|
+
|
|
18
23
|
attr_accessor :handlers
|
|
19
24
|
|
|
20
25
|
# Error raised when trying to modify the stack after calling `lock!`
|
|
@@ -211,11 +216,6 @@ module Faraday
|
|
|
211
216
|
|
|
212
217
|
private
|
|
213
218
|
|
|
214
|
-
LOCK_ERR = "can't modify middleware stack after making a request"
|
|
215
|
-
MISSING_ADAPTER_ERROR = "An attempt to run a request with a Faraday::Connection without adapter has been made.\n" \
|
|
216
|
-
"Please set Faraday.default_adapter or provide one when initializing the connection.\n" \
|
|
217
|
-
'For more info, check https://lostisland.github.io/faraday/usage/.'
|
|
218
|
-
|
|
219
219
|
def raise_if_locked
|
|
220
220
|
raise StackLocked, LOCK_ERR if locked?
|
|
221
221
|
end
|
|
@@ -15,7 +15,7 @@ module Faraday
|
|
|
15
15
|
404 => Faraday::ResourceNotFound,
|
|
16
16
|
408 => Faraday::RequestTimeoutError,
|
|
17
17
|
409 => Faraday::ConflictError,
|
|
18
|
-
422 => Faraday::
|
|
18
|
+
422 => Faraday::UnprocessableContentError,
|
|
19
19
|
429 => Faraday::TooManyRequestsError
|
|
20
20
|
}.freeze
|
|
21
21
|
# rubocop:enable Naming/ConstantName
|
data/lib/faraday/response.rb
CHANGED
|
@@ -33,6 +33,10 @@ module Faraday
|
|
|
33
33
|
finished? ? env.body : nil
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
def url
|
|
37
|
+
finished? ? env.url : nil
|
|
38
|
+
end
|
|
39
|
+
|
|
36
40
|
def finished?
|
|
37
41
|
!!env
|
|
38
42
|
end
|
|
@@ -60,9 +64,9 @@ module Faraday
|
|
|
60
64
|
|
|
61
65
|
def to_hash
|
|
62
66
|
{
|
|
63
|
-
status:
|
|
64
|
-
response_headers:
|
|
65
|
-
url:
|
|
67
|
+
status: status, body: body,
|
|
68
|
+
response_headers: headers,
|
|
69
|
+
url: url
|
|
66
70
|
}
|
|
67
71
|
end
|
|
68
72
|
|
|
@@ -51,7 +51,7 @@ module Faraday
|
|
|
51
51
|
|
|
52
52
|
def [](key)
|
|
53
53
|
key = KeyMap[key]
|
|
54
|
-
super
|
|
54
|
+
super || super(@names[key.downcase])
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def []=(key, val)
|
|
@@ -59,13 +59,13 @@ module Faraday
|
|
|
59
59
|
key = (@names[key.downcase] ||= key)
|
|
60
60
|
# join multiple values with a comma
|
|
61
61
|
val = val.to_ary.join(', ') if val.respond_to?(:to_ary)
|
|
62
|
-
super
|
|
62
|
+
super
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
def fetch(key, ...)
|
|
66
66
|
key = KeyMap[key]
|
|
67
67
|
key = @names.fetch(key.downcase, key)
|
|
68
|
-
super
|
|
68
|
+
super
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def delete(key)
|
|
@@ -74,13 +74,13 @@ module Faraday
|
|
|
74
74
|
return unless key
|
|
75
75
|
|
|
76
76
|
@names.delete key.downcase
|
|
77
|
-
super
|
|
77
|
+
super
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def dig(key, *rest)
|
|
81
81
|
key = KeyMap[key]
|
|
82
82
|
key = @names.fetch(key.downcase, key)
|
|
83
|
-
super
|
|
83
|
+
super
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def include?(key)
|
data/lib/faraday/version.rb
CHANGED
|
@@ -311,6 +311,46 @@ RSpec.describe Faraday::Connection do
|
|
|
311
311
|
end
|
|
312
312
|
end
|
|
313
313
|
|
|
314
|
+
context 'with protocol-relative URL (GHSA-33mh-2634-fwr2)' do
|
|
315
|
+
it 'does not allow host override with //evil.com/path' do
|
|
316
|
+
conn.url_prefix = 'http://httpbingo.org/api'
|
|
317
|
+
uri = conn.build_exclusive_url('//evil.com/path')
|
|
318
|
+
expect(uri.host).to eq('httpbingo.org')
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
it 'does not allow host override with URI("//evil.com/path")' do
|
|
322
|
+
conn.url_prefix = 'http://httpbingo.org/api'
|
|
323
|
+
uri = conn.build_exclusive_url(URI('//evil.com/path?token=1'))
|
|
324
|
+
expect(uri.host).to eq('httpbingo.org')
|
|
325
|
+
expect(uri.query).to eq('token=1')
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
it 'does not allow host override with //evil.com:8080/path' do
|
|
329
|
+
conn.url_prefix = 'http://httpbingo.org/api'
|
|
330
|
+
uri = conn.build_exclusive_url('//evil.com:8080/path')
|
|
331
|
+
expect(uri.host).to eq('httpbingo.org')
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
it 'does not allow host override with //user:pass@evil.com/path' do
|
|
335
|
+
conn.url_prefix = 'http://httpbingo.org/api'
|
|
336
|
+
uri = conn.build_exclusive_url('//user:pass@evil.com/path')
|
|
337
|
+
expect(uri.host).to eq('httpbingo.org')
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
it 'does not allow host override with ///evil.com' do
|
|
341
|
+
conn.url_prefix = 'http://httpbingo.org/api'
|
|
342
|
+
uri = conn.build_exclusive_url('///evil.com')
|
|
343
|
+
expect(uri.host).to eq('httpbingo.org')
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
it 'still allows single-slash absolute paths' do
|
|
347
|
+
conn.url_prefix = 'http://httpbingo.org/api'
|
|
348
|
+
uri = conn.build_exclusive_url('/safe/path')
|
|
349
|
+
expect(uri.host).to eq('httpbingo.org')
|
|
350
|
+
expect(uri.path).to eq('/safe/path')
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
|
|
314
354
|
context 'with a custom `default_uri_parser`' do
|
|
315
355
|
let(:url) { 'http://httpbingo.org' }
|
|
316
356
|
let(:parser) { Addressable::URI }
|
|
@@ -52,14 +52,14 @@ RSpec.describe Faraday::Middleware do
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
describe '#close' do
|
|
55
|
-
context "with app that doesn't support
|
|
55
|
+
context "with app that doesn't support #close" do
|
|
56
56
|
it 'should issue warning' do
|
|
57
57
|
is_expected.to receive(:warn)
|
|
58
58
|
subject.close
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
context
|
|
62
|
+
context 'with app that supports #close' do
|
|
63
63
|
it 'should issue warning' do
|
|
64
64
|
expect(app).to receive(:close)
|
|
65
65
|
is_expected.to_not receive(:warn)
|
|
@@ -31,6 +31,15 @@ RSpec.describe Faraday::Request do
|
|
|
31
31
|
it { expect(subject.to_env(conn).url.to_s).to eq('http://httpbingo.org/api/foo.json?a=1') }
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
context 'when setting the url on setup with a protocol-relative URI' do
|
|
35
|
+
let(:block) { proc { |req| req.url URI.parse('//evil.com/path?token=1') } }
|
|
36
|
+
let(:url) { subject.to_env(conn).url }
|
|
37
|
+
|
|
38
|
+
it { expect(url.host).to eq('httpbingo.org') }
|
|
39
|
+
it { expect(url.path).to eq('/api///evil.com/path') }
|
|
40
|
+
it { expect(url.query).to eq('token=1') }
|
|
41
|
+
end
|
|
42
|
+
|
|
34
43
|
context 'when setting the url on setup with a string path and params' do
|
|
35
44
|
let(:block) { proc { |req| req.url 'foo.json', 'a' => 1 } }
|
|
36
45
|
|
|
@@ -106,7 +106,7 @@ RSpec.describe Faraday::Response::Json, type: :response do
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it 'passes relevant options to JSON parse' do
|
|
109
|
-
expect(
|
|
109
|
+
expect(JSON).to receive(:parse)
|
|
110
110
|
.with(body, options[:parser_options])
|
|
111
111
|
.and_return(result)
|
|
112
112
|
|
|
@@ -21,6 +21,7 @@ RSpec.describe Faraday::Response::Logger do
|
|
|
21
21
|
stubs.post('/ohai') { [200, { 'Content-Type' => 'text/html' }, 'fred'] }
|
|
22
22
|
stubs.post('/ohyes') { [200, { 'Content-Type' => 'text/html' }, 'pebbles'] }
|
|
23
23
|
stubs.get('/rubbles') { [200, { 'Content-Type' => 'application/json' }, rubbles] }
|
|
24
|
+
stubs.get('/8bit') { [200, { 'Content-Type' => 'text/html' }, (+'café!').force_encoding(Encoding::ASCII_8BIT)] }
|
|
24
25
|
stubs.get('/filtered_body') { [200, { 'Content-Type' => 'text/html' }, 'soylent green is people'] }
|
|
25
26
|
stubs.get('/filtered_headers') { [200, { 'Content-Type' => 'text/html' }, 'headers response'] }
|
|
26
27
|
stubs.get('/filtered_params') { [200, { 'Content-Type' => 'text/html' }, 'params response'] }
|
|
@@ -217,7 +218,7 @@ RSpec.describe Faraday::Response::Logger do
|
|
|
217
218
|
|
|
218
219
|
it 'logs response body object' do
|
|
219
220
|
conn.get '/rubbles', nil, accept: 'text/html'
|
|
220
|
-
expect(string_io.string).to match(%([
|
|
221
|
+
expect(string_io.string).to match(%(["Barney", "Betty", "Bam Bam"]\n))
|
|
221
222
|
end
|
|
222
223
|
|
|
223
224
|
it 'logs filter body' do
|
|
@@ -238,6 +239,11 @@ RSpec.describe Faraday::Response::Logger do
|
|
|
238
239
|
expect(string_io.string).to match(%(fred))
|
|
239
240
|
end
|
|
240
241
|
|
|
242
|
+
it 'converts to UTF-8' do
|
|
243
|
+
conn.get '/8bit'
|
|
244
|
+
expect(string_io.string).to match(%(caf��!))
|
|
245
|
+
end
|
|
246
|
+
|
|
241
247
|
after do
|
|
242
248
|
described_class.default_options = { bodies: false }
|
|
243
249
|
end
|
|
@@ -13,7 +13,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
|
13
13
|
stub.get('proxy-error') { [407, { 'X-Reason' => 'because' }, 'keep looking'] }
|
|
14
14
|
stub.get('request-timeout') { [408, { 'X-Reason' => 'because' }, 'keep looking'] }
|
|
15
15
|
stub.get('conflict') { [409, { 'X-Reason' => 'because' }, 'keep looking'] }
|
|
16
|
-
stub.get('unprocessable-
|
|
16
|
+
stub.get('unprocessable-content') { [422, { 'X-Reason' => 'because' }, 'keep looking'] }
|
|
17
17
|
stub.get('too-many-requests') { [429, { 'X-Reason' => 'because' }, 'keep looking'] }
|
|
18
18
|
stub.get('4xx') { [499, { 'X-Reason' => 'because' }, 'keep looking'] }
|
|
19
19
|
stub.get('nil-status') { [nil, { 'X-Reason' => 'nil' }, 'fail'] }
|
|
@@ -103,9 +103,20 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
it 'raises Faraday::UnprocessableEntityError for 422 responses' do
|
|
107
|
-
expect { conn.get('unprocessable-
|
|
108
|
-
expect(ex.message).to eq('the server responded with status 422 for GET http:/unprocessable-
|
|
106
|
+
it 'raises legacy Faraday::UnprocessableEntityError for 422 responses' do
|
|
107
|
+
expect { conn.get('unprocessable-content') }.to raise_error(Faraday::UnprocessableEntityError) do |ex|
|
|
108
|
+
expect(ex.message).to eq('the server responded with status 422 for GET http:/unprocessable-content')
|
|
109
|
+
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
|
110
|
+
expect(ex.response[:status]).to eq(422)
|
|
111
|
+
expect(ex.response_status).to eq(422)
|
|
112
|
+
expect(ex.response_body).to eq('keep looking')
|
|
113
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'raises Faraday::UnprocessableContentError for 422 responses' do
|
|
118
|
+
expect { conn.get('unprocessable-content') }.to raise_error(Faraday::UnprocessableContentError) do |ex|
|
|
119
|
+
expect(ex.message).to eq('the server responded with status 422 for GET http:/unprocessable-content')
|
|
109
120
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
|
110
121
|
expect(ex.response[:status]).to eq(422)
|
|
111
122
|
expect(ex.response_status).to eq(422)
|
|
@@ -13,6 +13,7 @@ RSpec.describe Faraday::Response do
|
|
|
13
13
|
it { expect(subject.success?).to be_falsey }
|
|
14
14
|
it { expect(subject.status).to eq(404) }
|
|
15
15
|
it { expect(subject.body).to eq('yikes') }
|
|
16
|
+
it { expect(subject.url).to eq(URI('https://lostisland.github.io/faraday')) }
|
|
16
17
|
it { expect(subject.headers['Content-Type']).to eq('text/plain') }
|
|
17
18
|
it { expect(subject['content-type']).to eq('text/plain') }
|
|
18
19
|
|
|
@@ -31,6 +32,12 @@ RSpec.describe Faraday::Response do
|
|
|
31
32
|
it { expect(hash[:response_headers]).to eq(subject.headers) }
|
|
32
33
|
it { expect(hash[:body]).to eq(subject.body) }
|
|
33
34
|
it { expect(hash[:url]).to eq(subject.env.url) }
|
|
35
|
+
|
|
36
|
+
context 'when response is not finished' do
|
|
37
|
+
subject { Faraday::Response.new.to_hash }
|
|
38
|
+
|
|
39
|
+
it { is_expected.to eq({ status: nil, body: nil, response_headers: {}, url: nil }) }
|
|
40
|
+
end
|
|
34
41
|
end
|
|
35
42
|
|
|
36
43
|
describe 'marshal serialization support' do
|
data/spec/faraday/utils_spec.rb
CHANGED
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.14.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- "@technoweenie"
|
|
@@ -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.14.2
|
|
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'
|