faraday 2.7.10 → 2.7.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4aa57af93476ba31117b14ed37bea950bf9b677d4dcca13ca1296a3ac2c3ff7
4
- data.tar.gz: 98b3cb7b7c5c08eba9f58ad96181757d6cd7fc7431ac47ae19e8c95a25de12f9
3
+ metadata.gz: 72fbb1db4fce28541cd53b5908e1fc18539ead8322d0b642069bd2e63d2a6543
4
+ data.tar.gz: a5e4f596d8f23e00f064c9789f85fa1cb194cac85168177750b76b3a3e9c7f4d
5
5
  SHA512:
6
- metadata.gz: 28f98f568e844799353a00d5ff49511f7bdb759a50edd3de2d4194fbb348dc14d1ef0294d854016ccdcbec915546225ebb2cf6dec354d6e7fbbf707b00cfc170
7
- data.tar.gz: 3506cebb9ad1fbd1dd38c1804e18cfd7d7352796d11fa564cde9ce0eee1b1a8ba6d07acda4b179662e5b6eb23baf6f70173240cf8a6b69834d2db9c740a80e25
6
+ metadata.gz: f880cdd4a42f22ac4eafeab1ddfcfb9e7a8ff0299956a279b207e4ed50d9b86fa09e44e74c4810b9ace3748db5edf6a9f62c73310d09ec1bbf73ec981356d921
7
+ data.tar.gz: 159e971ec7168017e0053511217a8b89314cd25aaf626a3a409db800218e39b172741a1264616c7b770a3ce45e9ee9a0bd5f9dc6fd43511cc4b9f8ae5fa8304a
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [![Faraday](./docs/assets/img/repo-card-slim.png)][website]
1
+ # [![Faraday](./docs/_media/home-logo.svg)][website]
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)
@@ -6,14 +6,29 @@
6
6
 
7
7
  Faraday is an HTTP client library abstraction layer that provides a common interface over many
8
8
  adapters (such as Net::HTTP) and embraces the concept of Rack middleware when processing the request/response cycle.
9
- You probably don't want to use Faraday directly in your project, as it will lack an actual client library to perform
10
- requests. Instead, you probably want to have a look at [Awesome Faraday][awesome] for a list of available adapters.
9
+ Take a look at [Awesome Faraday][awesome] for a list of available adapters and middleware.
10
+
11
+ ## Why use Faraday?
12
+
13
+ Faraday gives you the power of Rack middleware for manipulating HTTP requests and responses,
14
+ making it easier to build sophisticated API clients or web service libraries that abstract away
15
+ the details of how HTTP requests are made.
16
+
17
+ Faraday comes with a lot of features out of the box, such as:
18
+ * Support for multiple adapters (Net::HTTP, Typhoeus, Patron, Excon, HTTPClient, and more)
19
+ * Persistent connections (keep-alive)
20
+ * Parallel requests
21
+ * Automatic response parsing (JSON, XML, YAML)
22
+ * Customization of the request/response cycle with middleware
23
+ * Support for streaming responses
24
+ * Support for uploading files
25
+ * And much more!
11
26
 
12
27
  ## Getting Started
13
28
 
14
29
  The best starting point is the [Faraday Website][website], with its introduction and explanation.
15
30
 
16
- Need more details? See the [Faraday API Documentation][apidoc] to see how it works internally, or take a look at [Advanced techniques for calling HTTP APIs in Ruby](https://mattbrictson.com/blog/advanced-http-techniques-in-ruby) blog post from @mattbrictson 🚀
31
+ Need more details? See the [Faraday API Documentation][apidoc] to see how it works internally, or take a look at [Advanced techniques for calling HTTP APIs in Ruby](https://mattbrictson.com/blog/advanced-http-techniques-in-ruby) blog post from [@mattbrictson](https://github.com/mattbrictson) 🚀
17
32
 
18
33
  ## Supported Ruby versions
19
34
 
@@ -43,14 +58,10 @@ But before you start coding, please read our [Contributing Guide][contributing]
43
58
 
44
59
  ## Copyright
45
60
 
46
- © 2009 - 2023, the [Faraday Team][faraday_team]. Website and branding design by [Elena Lo Piccolo](https://elelopic.design).
61
+ © 2009 - 2023, the Faraday Team. Website and branding design by [Elena Lo Piccolo](https://elelopic.design).
47
62
 
48
63
  [awesome]: https://github.com/lostisland/awesome-faraday/#adapters
49
64
  [website]: https://lostisland.github.io/faraday
50
- [faraday_team]: https://lostisland.github.io/faraday/team
51
- [contributing]: https://github.com/lostisland/faraday/blob/master/.github/CONTRIBUTING.md
65
+ [contributing]: https://github.com/lostisland/faraday/blob/main/.github/CONTRIBUTING.md
52
66
  [apidoc]: https://www.rubydoc.info/github/lostisland/faraday
53
67
  [actions]: https://github.com/lostisland/faraday/actions
54
- [jruby]: http://jruby.org/
55
- [rubinius]: http://rubini.us/
56
- [license]: LICENSE.md
@@ -39,11 +39,26 @@ module Faraday
39
39
  end
40
40
  end
41
41
 
42
+ # Returns a hash of response data with the following keys:
43
+ # - status
44
+ # - headers
45
+ # - body
46
+ # - request
47
+ #
48
+ # The `request` key is omitted when the middleware is explicitly
49
+ # configured with the option `include_request: false`.
42
50
  def response_values(env)
43
- {
51
+ response = {
44
52
  status: env.status,
45
53
  headers: env.response_headers,
46
- body: env.body,
54
+ body: env.body
55
+ }
56
+
57
+ # Include the request data by default. If the middleware was explicitly
58
+ # configured to _not_ include request data, then omit it.
59
+ return response unless options.fetch(:include_request, true)
60
+
61
+ response.merge(
47
62
  request: {
48
63
  method: env.method,
49
64
  url: env.url,
@@ -52,7 +67,7 @@ module Faraday
52
67
  headers: env.request_headers,
53
68
  body: env.request_body
54
69
  }
55
- }
70
+ )
56
71
  end
57
72
 
58
73
  def query_params(env)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- VERSION = '2.7.10'
4
+ VERSION = '2.7.11'
5
5
  end
@@ -149,7 +149,7 @@ RSpec.describe Faraday::Response::RaiseError do
149
149
  describe 'request info' do
150
150
  let(:conn) do
151
151
  Faraday.new do |b|
152
- b.response :raise_error
152
+ b.response :raise_error, **middleware_options
153
153
  b.adapter :test do |stub|
154
154
  stub.post(url, request_body, request_headers) do
155
155
  [400, { 'X-Reason' => 'because' }, 'keep looking']
@@ -157,6 +157,7 @@ RSpec.describe Faraday::Response::RaiseError do
157
157
  end
158
158
  end
159
159
  end
160
+ let(:middleware_options) { {} }
160
161
  let(:request_body) { JSON.generate({ 'item' => 'sth' }) }
161
162
  let(:request_headers) { { 'Authorization' => 'Basic 123' } }
162
163
  let(:url_path) { 'request' }
@@ -180,5 +181,19 @@ RSpec.describe Faraday::Response::RaiseError do
180
181
  expect(ex.response[:request][:body]).to eq(request_body)
181
182
  end
182
183
  end
184
+
185
+ context 'when the include_request option is set to false' do
186
+ let(:middleware_options) { { include_request: false } }
187
+
188
+ it 'does not include request info in the exception' do
189
+ expect { perform_request }.to raise_error(Faraday::BadRequestError) do |ex|
190
+ expect(ex.response.keys).to contain_exactly(
191
+ :status,
192
+ :headers,
193
+ :body
194
+ )
195
+ end
196
+ end
197
+ end
183
198
  end
184
199
  end
data/spec/faraday_spec.rb CHANGED
@@ -18,10 +18,14 @@ RSpec.describe Faraday do
18
18
  end
19
19
 
20
20
  it 'uses method_missing on Faraday if there is no proxyable method' do
21
- expect { Faraday.this_method_does_not_exist }.to raise_error(
22
- NoMethodError,
23
- "undefined method `this_method_does_not_exist' for Faraday:Module"
24
- )
21
+ expected_message =
22
+ if RUBY_VERSION >= '3.3'
23
+ "undefined method `this_method_does_not_exist' for module Faraday"
24
+ else
25
+ "undefined method `this_method_does_not_exist' for Faraday:Module"
26
+ end
27
+
28
+ expect { Faraday.this_method_does_not_exist }.to raise_error(NoMethodError, expected_message)
25
29
  end
26
30
 
27
31
  it 'proxied methods can be accessed' 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.7.10
4
+ version: 2.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@technoweenie"
@@ -10,8 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-07-06 00:00:00.000000000 Z
13
+ date: 2023-09-12 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: base64
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: faraday-net_http
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -131,7 +145,7 @@ licenses:
131
145
  - MIT
132
146
  metadata:
133
147
  homepage_uri: https://lostisland.github.io/faraday
134
- changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.7.10
148
+ changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.7.11
135
149
  source_code_uri: https://github.com/lostisland/faraday
136
150
  bug_tracker_uri: https://github.com/lostisland/faraday/issues
137
151
  post_install_message: