faraday 2.12.2 → 2.13.1

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: bfb424c45e703a33fd819b31c8ee41c9e4e30874b280530a19ce8ae320570ef9
4
- data.tar.gz: c1a1a5b7aab4f393908958701959f7b41fd303ca4da906c1b4c0581a13c590db
3
+ metadata.gz: 7ab8d55c7b360596e25721ecc32dcf99c65cea19d04598bb468fc2a422e26146
4
+ data.tar.gz: 624ddc291aec0a438fded658897b2127d62b8fe10e00590e3ad0a609307711d6
5
5
  SHA512:
6
- metadata.gz: 6d4d18e2006ac83dfd22aff834b4fe3c983bfbf578b6850944d35cfbb1ca40ba58ce07414821bc3e604ca3310c85500d5d2b8de7c33b0e6147f24484fcae688f
7
- data.tar.gz: 9cc8057d003f09a02bbdb9a29b920003beff58391c3bf86838ae61b2e9aaac4782d5764286f824b24d486e8dee202cc2d892ec3f658db6b710d5088d5836be3c
6
+ metadata.gz: e2394c6ccb0b3e12d16e2dcd739d8ecf053199b40ce5d8d4a1902cc141c12746190e21b928e4979405ffcb2660db80a4777d46ee839df10f75cb66b34039285e
7
+ data.tar.gz: d91f5258bb49c40ff720aaba295ab4c86ea975cb7e0d4ad96647921e34924013501c1b4dddcf1c5497488fda0480ef39296f76b16188201f0162da004a490ba5
@@ -60,7 +60,7 @@ module Faraday
60
60
  :reason_phrase, :response_body) do
61
61
  const_set(:ContentLength, 'Content-Length')
62
62
  const_set(:StatusesWithoutBody, Set.new([204, 304]))
63
- const_set(:SuccessfulStatuses, (200..299))
63
+ const_set(:SuccessfulStatuses, 200..299)
64
64
 
65
65
  # A Set of HTTP verbs that typically send a body. If no body is set for
66
66
  # these requests, the Content-Length header is set to 0.
@@ -22,8 +22,10 @@ module Faraday
22
22
  when URI
23
23
  value = { uri: value }
24
24
  when Hash, Options
25
- if (uri = value.delete(:uri))
26
- value[:uri] = Utils.URI(uri)
25
+ if value[:uri]
26
+ value = value.dup.tap do |duped|
27
+ duped[:uri] = Utils.URI(duped[:uri])
28
+ end
27
29
  end
28
30
  end
29
31
 
@@ -11,6 +11,9 @@ module Faraday
11
11
  # # @return [Boolean] whether to enable hostname verification on server certificates
12
12
  # # during the handshake or not (see https://github.com/ruby/openssl/pull/60)
13
13
  # #
14
+ # # @!attribute hostname
15
+ # # @return [String] Server hostname used for SNI (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLSocket.html#method-i-hostname-3D)
16
+ # #
14
17
  # # @!attribute ca_file
15
18
  # # @return [String] CA file
16
19
  # #
@@ -50,7 +53,7 @@ module Faraday
50
53
  # # @!attribute ciphers
51
54
  # # @return [String] cipher list in OpenSSL format (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html#method-i-ciphers-3D)
52
55
  # class SSLOptions < Options; end
53
- SSLOptions = Options.new(:verify, :verify_hostname,
56
+ SSLOptions = Options.new(:verify, :verify_hostname, :hostname,
54
57
  :ca_file, :ca_path, :verify_mode,
55
58
  :cert_store, :client_cert, :client_key,
56
59
  :certificate, :private_key, :verify_depth,
@@ -27,10 +27,11 @@ module Faraday
27
27
 
28
28
  attr_reader :name
29
29
 
30
- ruby2_keywords def initialize(klass, *args, &block)
30
+ def initialize(klass, *args, **kwargs, &block)
31
31
  @name = klass.to_s
32
32
  REGISTRY.set(klass) if klass.respond_to?(:name)
33
33
  @args = args
34
+ @kwargs = kwargs
34
35
  @block = block
35
36
  end
36
37
 
@@ -53,7 +54,7 @@ module Faraday
53
54
  end
54
55
 
55
56
  def build(app = nil)
56
- klass.new(app, *@args, &@block)
57
+ klass.new(app, *@args, **@kwargs, &@block)
57
58
  end
58
59
  end
59
60
 
@@ -106,11 +107,11 @@ module Faraday
106
107
  use_symbol(Faraday::Response, ...)
107
108
  end
108
109
 
109
- ruby2_keywords def adapter(klass = NO_ARGUMENT, *args, &block)
110
+ def adapter(klass = NO_ARGUMENT, *args, **kwargs, &block)
110
111
  return @adapter if klass == NO_ARGUMENT || klass.nil?
111
112
 
112
113
  klass = Faraday::Adapter.lookup_middleware(klass) if klass.is_a?(Symbol)
113
- @adapter = self.class::Handler.new(klass, *args, &block)
114
+ @adapter = self.class::Handler.new(klass, *args, **kwargs, &block)
114
115
  end
115
116
 
116
117
  ## methods to push onto the various positions in the stack:
@@ -10,11 +10,13 @@ module Faraday
10
10
  # lifecycle to a given Logger object. By default, this logs to STDOUT. See
11
11
  # Faraday::Logging::Formatter to see specifically what is logged.
12
12
  class Logger < Middleware
13
+ DEFAULT_OPTIONS = { formatter: Logging::Formatter }.merge(Logging::Formatter::DEFAULT_OPTIONS).freeze
14
+
13
15
  def initialize(app, logger = nil, options = {})
14
- super(app)
16
+ super(app, options)
15
17
  logger ||= ::Logger.new($stdout)
16
- formatter_class = options.delete(:formatter) || Logging::Formatter
17
- @formatter = formatter_class.new(logger: logger, options: options)
18
+ formatter_class = @options.delete(:formatter)
19
+ @formatter = formatter_class.new(logger: logger, options: @options)
18
20
  yield @formatter if block_given?
19
21
  end
20
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- VERSION = '2.12.2'
4
+ VERSION = '2.13.1'
5
5
  end
@@ -27,6 +27,33 @@ RSpec.describe Faraday::ProxyOptions do
27
27
  expect(options.inspect).to eq('#<Faraday::ProxyOptions (empty)>')
28
28
  end
29
29
 
30
+ it 'works with hash' do
31
+ hash = { user: 'user', password: 'pass', uri: 'http://@example.org' }
32
+ options = Faraday::ProxyOptions.from(hash)
33
+ expect(options.user).to eq('user')
34
+ expect(options.password).to eq('pass')
35
+ expect(options.uri).to be_a_kind_of(URI)
36
+ expect(options.path).to eq('')
37
+ expect(options.port).to eq(80)
38
+ expect(options.host).to eq('example.org')
39
+ expect(options.scheme).to eq('http')
40
+ expect(options.inspect).to match('#<Faraday::ProxyOptions uri=')
41
+ end
42
+
43
+ it 'works with option' do
44
+ opt_arg = { user: 'user', password: 'pass', uri: 'http://@example.org' }
45
+ option = Faraday::ConnectionOptions.from(proxy: opt_arg)
46
+ options = Faraday::ProxyOptions.from(option.proxy)
47
+ expect(options.user).to eq('user')
48
+ expect(options.password).to eq('pass')
49
+ expect(options.uri).to be_a_kind_of(URI)
50
+ expect(options.path).to eq('')
51
+ expect(options.port).to eq(80)
52
+ expect(options.host).to eq('example.org')
53
+ expect(options.scheme).to eq('http')
54
+ expect(options.inspect).to match('#<Faraday::ProxyOptions uri=')
55
+ end
56
+
30
57
  it 'works with no auth' do
31
58
  proxy = Faraday::ProxyOptions.from 'http://example.org'
32
59
  expect(proxy.user).to be_nil
@@ -189,7 +189,7 @@ RSpec.describe Faraday::Response::Logger do
189
189
  context 'when logging request body' do
190
190
  let(:logger_options) { { bodies: { request: true } } }
191
191
 
192
- it 'log only request body' do
192
+ it 'logs only request body' do
193
193
  conn.post '/ohyes', 'name=Tamago', accept: 'text/html'
194
194
  expect(string_io.string).to match(%(name=Tamago))
195
195
  expect(string_io.string).not_to match(%(pebbles))
@@ -199,7 +199,7 @@ RSpec.describe Faraday::Response::Logger do
199
199
  context 'when logging response body' do
200
200
  let(:logger_options) { { bodies: { response: true } } }
201
201
 
202
- it 'log only response body' do
202
+ it 'logs only response body' do
203
203
  conn.post '/ohyes', 'name=Hamachi', accept: 'text/html'
204
204
  expect(string_io.string).to match(%(pebbles))
205
205
  expect(string_io.string).not_to match(%(name=Hamachi))
@@ -209,13 +209,13 @@ RSpec.describe Faraday::Response::Logger do
209
209
  context 'when logging request and response bodies' do
210
210
  let(:logger_options) { { bodies: true } }
211
211
 
212
- it 'log request and response body' do
212
+ it 'logs request and response body' do
213
213
  conn.post '/ohyes', 'name=Ebi', accept: 'text/html'
214
214
  expect(string_io.string).to match(%(name=Ebi))
215
215
  expect(string_io.string).to match(%(pebbles))
216
216
  end
217
217
 
218
- it 'log response body object' do
218
+ it 'logs response body object' do
219
219
  conn.get '/rubbles', nil, accept: 'text/html'
220
220
  expect(string_io.string).to match(%([\"Barney\", \"Betty\", \"Bam Bam\"]\n))
221
221
  end
@@ -228,6 +228,21 @@ RSpec.describe Faraday::Response::Logger do
228
228
  end
229
229
  end
230
230
 
231
+ context 'when bodies are logged by default' do
232
+ before do
233
+ described_class.default_options = { bodies: true }
234
+ end
235
+
236
+ it 'logs response body' do
237
+ conn.post '/ohai'
238
+ expect(string_io.string).to match(%(fred))
239
+ end
240
+
241
+ after do
242
+ described_class.default_options = { bodies: false }
243
+ end
244
+ end
245
+
231
246
  context 'when logging errors' do
232
247
  let(:logger_options) { { errors: true } }
233
248
 
@@ -104,6 +104,7 @@ RSpec.describe Faraday::Utils do
104
104
  min_version: nil,
105
105
  max_version: nil,
106
106
  verify_hostname: nil,
107
+ hostname: nil,
107
108
  ciphers: nil
108
109
  }
109
110
  end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.2
4
+ version: 2.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@technoweenie"
8
8
  - "@iMacTia"
9
9
  - "@olleolleolle"
10
- autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2024-12-09 00:00:00.000000000 Z
12
+ date: 1980-01-02 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: faraday-net_http
@@ -60,7 +59,6 @@ dependencies:
60
59
  - - ">="
61
60
  - !ruby/object:Gem::Version
62
61
  version: '0'
63
- description:
64
62
  email: technoweenie@gmail.com
65
63
  executables: []
66
64
  extensions: []
@@ -146,11 +144,10 @@ licenses:
146
144
  - MIT
147
145
  metadata:
148
146
  homepage_uri: https://lostisland.github.io/faraday
149
- changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.12.2
147
+ changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.13.1
150
148
  source_code_uri: https://github.com/lostisland/faraday
151
149
  bug_tracker_uri: https://github.com/lostisland/faraday/issues
152
150
  rubygems_mfa_required: 'true'
153
- post_install_message:
154
151
  rdoc_options: []
155
152
  require_paths:
156
153
  - lib
@@ -166,8 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
163
  - !ruby/object:Gem::Version
167
164
  version: '0'
168
165
  requirements: []
169
- rubygems_version: 3.5.22
170
- signing_key:
166
+ rubygems_version: 3.6.7
171
167
  specification_version: 4
172
168
  summary: HTTP/REST API client library.
173
169
  test_files: []