faraday 2.7.11 → 2.7.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72fbb1db4fce28541cd53b5908e1fc18539ead8322d0b642069bd2e63d2a6543
4
- data.tar.gz: a5e4f596d8f23e00f064c9789f85fa1cb194cac85168177750b76b3a3e9c7f4d
3
+ metadata.gz: 975b437b7cfe03559c0c2affea747fb2bc10c8439d1f05c8f901261ebf8ff956
4
+ data.tar.gz: aa20a42dc8dbd47d970e28000cbf693e39c80a3806d6b3f5348759858e7d4812
5
5
  SHA512:
6
- metadata.gz: f880cdd4a42f22ac4eafeab1ddfcfb9e7a8ff0299956a279b207e4ed50d9b86fa09e44e74c4810b9ace3748db5edf6a9f62c73310d09ec1bbf73ec981356d921
7
- data.tar.gz: 159e971ec7168017e0053511217a8b89314cd25aaf626a3a409db800218e39b172741a1264616c7b770a3ce45e9ee9a0bd5f9dc6fd43511cc4b9f8ae5fa8304a
6
+ metadata.gz: 31eaeb27af10b33774afbb9c83d46a2c310dd422602345c94d198737a1f1ff95692aa48235e47082177b15f540caaa4c3733bd739b17375da71f02851913e353
7
+ data.tar.gz: 6d610f6e22f77447b0eaef8ab5c5cd424e119a1db1f654affd1eb1dd9f6064ba53f837ba0e36130a2454826656f7113aba54af0c393ac9dae6f255468ae007ac
data/lib/faraday/error.rb CHANGED
@@ -124,6 +124,10 @@ module Faraday
124
124
  class UnprocessableEntityError < ClientError
125
125
  end
126
126
 
127
+ # Raised by Faraday::Response::RaiseError in case of a 429 response.
128
+ class TooManyRequestsError < ClientError
129
+ end
130
+
127
131
  # Faraday server error class. Represents 5xx status responses.
128
132
  class ServerError < Error
129
133
  end
@@ -30,6 +30,8 @@ module Faraday
30
30
  raise Faraday::ConflictError, response_values(env)
31
31
  when 422
32
32
  raise Faraday::UnprocessableEntityError, response_values(env)
33
+ when 429
34
+ raise Faraday::TooManyRequestsError, response_values(env)
33
35
  when ClientErrorStatuses
34
36
  raise Faraday::ClientError, response_values(env)
35
37
  when ServerErrorStatuses
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- VERSION = '2.7.11'
4
+ VERSION = '2.7.12'
5
5
  end
@@ -14,6 +14,7 @@ RSpec.describe Faraday::Response::RaiseError do
14
14
  stub.get('request-timeout') { [408, { 'X-Reason' => 'because' }, 'keep looking'] }
15
15
  stub.get('conflict') { [409, { 'X-Reason' => 'because' }, 'keep looking'] }
16
16
  stub.get('unprocessable-entity') { [422, { 'X-Reason' => 'because' }, 'keep looking'] }
17
+ stub.get('too-many-requests') { [429, { 'X-Reason' => 'because' }, 'keep looking'] }
17
18
  stub.get('4xx') { [499, { 'X-Reason' => 'because' }, 'keep looking'] }
18
19
  stub.get('nil-status') { [nil, { 'X-Reason' => 'nil' }, 'fail'] }
19
20
  stub.get('server-error') { [500, { 'X-Error' => 'bailout' }, 'fail'] }
@@ -113,6 +114,17 @@ RSpec.describe Faraday::Response::RaiseError do
113
114
  end
114
115
  end
115
116
 
117
+ it 'raises Faraday::TooManyRequestsError for 429 responses' do
118
+ expect { conn.get('too-many-requests') }.to raise_error(Faraday::TooManyRequestsError) do |ex|
119
+ expect(ex.message).to eq('the server responded with status 429')
120
+ expect(ex.response[:headers]['X-Reason']).to eq('because')
121
+ expect(ex.response[:status]).to eq(429)
122
+ expect(ex.response_status).to eq(429)
123
+ expect(ex.response_body).to eq('keep looking')
124
+ expect(ex.response_headers['X-Reason']).to eq('because')
125
+ end
126
+ end
127
+
116
128
  it 'raises Faraday::NilStatusError for nil status in response' do
117
129
  expect { conn.get('nil-status') }.to raise_error(Faraday::NilStatusError) do |ex|
118
130
  expect(ex.message).to eq('http status could not be derived from the server response')
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.7.11
4
+ version: 2.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@technoweenie"
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-09-12 00:00:00.000000000 Z
13
+ date: 2023-11-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: base64
@@ -145,7 +145,7 @@ licenses:
145
145
  - MIT
146
146
  metadata:
147
147
  homepage_uri: https://lostisland.github.io/faraday
148
- changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.7.11
148
+ changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.7.12
149
149
  source_code_uri: https://github.com/lostisland/faraday
150
150
  bug_tracker_uri: https://github.com/lostisland/faraday/issues
151
151
  post_install_message: