faraday 2.13.4 → 2.14.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/encoders/flat_params_encoder.rb +2 -2
- data/lib/faraday/error.rb +4 -1
- data/lib/faraday/logging/formatter.rb +1 -1
- data/lib/faraday/response/raise_error.rb +1 -1
- data/lib/faraday/response.rb +7 -3
- data/lib/faraday/version.rb +1 -1
- data/spec/faraday/response/logger_spec.rb +6 -0
- data/spec/faraday/response/raise_error_spec.rb +15 -4
- data/spec/faraday/response_spec.rb +7 -0
- 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: 2fc5e44f27171827ea964dee68999e7d9ae6cd4d952a0a8ad0600e155cdf3892
|
4
|
+
data.tar.gz: 88c85684e7d9acb7978b36d20f2041145441f99e7705e6cf8f41483ed620dadc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 972d764f70f42d46e01ef8c8a33aab692619b8adc1793f07ed031cc7cd09ad6d749d5948d25f4e9e8c6b83377bfa2a25eda1e80eb79d086bae93d90959e321bd
|
7
|
+
data.tar.gz: b9b7b80f59d02b813ae99ba5afd3cbaf517953f208f2cfc91347bdbec1f4112d4b508c22721f65ac607b45a47507d7adc97cbe7cf08b3d0c56ad0c7dc1b0af5e
|
@@ -76,9 +76,9 @@ module Faraday
|
|
76
76
|
|
77
77
|
empty_accumulator = {}
|
78
78
|
|
79
|
-
split_query =
|
79
|
+
split_query = query.split('&').filter_map do |pair|
|
80
80
|
pair.split('=', 2) if pair && !pair.empty?
|
81
|
-
end
|
81
|
+
end
|
82
82
|
split_query.each_with_object(empty_accumulator.dup) do |pair, accu|
|
83
83
|
pair[0] = unescape(pair[0])
|
84
84
|
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
|
@@ -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
|
|
data/lib/faraday/version.rb
CHANGED
@@ -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'] }
|
@@ -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
|
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.0
|
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.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'
|