faraday 2.14.3 → 2.14.4
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/LICENSE.md +1 -1
- data/README.md +1 -1
- data/lib/faraday/options/connection_options.rb +27 -0
- data/lib/faraday/options/proxy_options.rb +9 -0
- data/lib/faraday/options/request_options.rb +35 -0
- data/lib/faraday/response/json.rb +2 -2
- data/lib/faraday/version.rb +1 -1
- data/lib/faraday.rb +32 -0
- data/spec/faraday_spec.rb +26 -0
- data/spec/spec_helper.rb +11 -2
- 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: bfb9bdb4e8b26d58a269ecb088231f9b6b3fa41dcba2e45030e148e3fed39c85
|
|
4
|
+
data.tar.gz: f14d4a3d9fde7a433af42981764ef381347fbbe96414fe0f576a5d9e7d32c12e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f757a719af96c446b1c90a02ed43a190b551c489c72c4f158f041c8afdcec9385903e28f057929c217cdd29ed2a396316ffc650c66352be26503edd2a70eefa
|
|
7
|
+
data.tar.gz: b34d0e1b1816abc2ae2987088abc08153acc0786582e742fe384418e8b8fc3ae4f5ee14b3e768d1f06ba8b1b44b4a10effd61858297db08e47775cf712e7f190
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
|
@@ -58,7 +58,7 @@ But before you start coding, please read our [Contributing Guide][contributing]
|
|
|
58
58
|
|
|
59
59
|
## Copyright
|
|
60
60
|
|
|
61
|
-
© 2009 -
|
|
61
|
+
© 2009 - 2026, the Faraday Team. Website and branding design by [Elena Lo Piccolo](https://elelopic.design).
|
|
62
62
|
|
|
63
63
|
[awesome]: https://github.com/lostisland/awesome-faraday/#adapters
|
|
64
64
|
[website]: https://lostisland.github.io/faraday
|
|
@@ -4,6 +4,33 @@ module Faraday
|
|
|
4
4
|
# @!parse
|
|
5
5
|
# # ConnectionOptions contains the configurable properties for a Faraday
|
|
6
6
|
# # connection object.
|
|
7
|
+
# #
|
|
8
|
+
# # @!attribute request
|
|
9
|
+
# # @return [RequestOptions] default request options for the connection
|
|
10
|
+
# #
|
|
11
|
+
# # @!attribute proxy
|
|
12
|
+
# # @return [ProxyOptions] proxy options for the connection
|
|
13
|
+
# #
|
|
14
|
+
# # @!attribute ssl
|
|
15
|
+
# # @return [SSLOptions] SSL options for the connection
|
|
16
|
+
# #
|
|
17
|
+
# # @!attribute builder
|
|
18
|
+
# # @return [RackBuilder] the middleware stack builder for the connection
|
|
19
|
+
# #
|
|
20
|
+
# # @!attribute url
|
|
21
|
+
# # @return [String, URI] the base URL for the connection
|
|
22
|
+
# #
|
|
23
|
+
# # @!attribute parallel_manager
|
|
24
|
+
# # @return [Object] manager used when the connection runs in parallel mode
|
|
25
|
+
# #
|
|
26
|
+
# # @!attribute params
|
|
27
|
+
# # @return [Hash] default query parameters for the connection
|
|
28
|
+
# #
|
|
29
|
+
# # @!attribute headers
|
|
30
|
+
# # @return [Hash] default headers for the connection
|
|
31
|
+
# #
|
|
32
|
+
# # @!attribute builder_class
|
|
33
|
+
# # @return [Class] the class used to build the middleware stack
|
|
7
34
|
# class ConnectionOptions < Options; end
|
|
8
35
|
ConnectionOptions = Options.new(:request, :proxy, :ssl, :builder, :url,
|
|
9
36
|
:parallel_manager, :params, :headers,
|
|
@@ -4,6 +4,15 @@ module Faraday
|
|
|
4
4
|
# @!parse
|
|
5
5
|
# # ProxyOptions contains the configurable properties for the proxy
|
|
6
6
|
# # configuration used when making an HTTP request.
|
|
7
|
+
# #
|
|
8
|
+
# # @!attribute uri
|
|
9
|
+
# # @return [URI] the proxy server URI
|
|
10
|
+
# #
|
|
11
|
+
# # @!attribute user
|
|
12
|
+
# # @return [String] the proxy server username
|
|
13
|
+
# #
|
|
14
|
+
# # @!attribute password
|
|
15
|
+
# # @return [String] the proxy server password
|
|
7
16
|
# class ProxyOptions < Options; end
|
|
8
17
|
ProxyOptions = Options.new(:uri, :user, :password) do
|
|
9
18
|
extend Forwardable
|
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
module Faraday
|
|
4
4
|
# @!parse
|
|
5
5
|
# # RequestOptions contains the configurable properties for a Faraday request.
|
|
6
|
+
# #
|
|
7
|
+
# # @!attribute params_encoder
|
|
8
|
+
# # @return [Object] the params encoder used to serialize the request params
|
|
9
|
+
# #
|
|
10
|
+
# # @!attribute proxy
|
|
11
|
+
# # @return [ProxyOptions] proxy options for this request
|
|
12
|
+
# #
|
|
13
|
+
# # @!attribute bind
|
|
14
|
+
# # @return [Hash] the local host and port to bind the connection to
|
|
15
|
+
# #
|
|
16
|
+
# # @!attribute timeout
|
|
17
|
+
# # @return [Integer] time limit for the entire request (in seconds)
|
|
18
|
+
# #
|
|
19
|
+
# # @!attribute open_timeout
|
|
20
|
+
# # @return [Integer] time limit for just the connection phase (in seconds)
|
|
21
|
+
# #
|
|
22
|
+
# # @!attribute read_timeout
|
|
23
|
+
# # @return [Integer] time limit for the first response byte received from
|
|
24
|
+
# # the server (in seconds)
|
|
25
|
+
# #
|
|
26
|
+
# # @!attribute write_timeout
|
|
27
|
+
# # @return [Integer] time limit for the client to send the request to the
|
|
28
|
+
# # server (in seconds)
|
|
29
|
+
# #
|
|
30
|
+
# # @!attribute boundary
|
|
31
|
+
# # @return [String] the boundary used for multipart request bodies
|
|
32
|
+
# #
|
|
33
|
+
# # @!attribute oauth
|
|
34
|
+
# # @return [Hash] OAuth options used by the OAuth middleware
|
|
35
|
+
# #
|
|
36
|
+
# # @!attribute context
|
|
37
|
+
# # @return [Hash] free-form storage carried alongside the request
|
|
38
|
+
# #
|
|
39
|
+
# # @!attribute on_data
|
|
40
|
+
# # @return [Proc] callback invoked with each chunk when streaming the response
|
|
6
41
|
# class RequestOptions < Options; end
|
|
7
42
|
RequestOptions = Options.new(:params_encoder, :proxy, :bind,
|
|
8
43
|
:timeout, :open_timeout, :read_timeout,
|
|
@@ -8,7 +8,7 @@ module Faraday
|
|
|
8
8
|
class Json < Middleware
|
|
9
9
|
def initialize(app = nil, parser_options: nil, content_type: /\bjson$/, preserve_raw: false)
|
|
10
10
|
super(app)
|
|
11
|
-
@parser_options = parser_options
|
|
11
|
+
@parser_options = parser_options&.dup
|
|
12
12
|
@content_types = Array(content_type)
|
|
13
13
|
@preserve_raw = preserve_raw
|
|
14
14
|
|
|
@@ -33,7 +33,7 @@ module Faraday
|
|
|
33
33
|
|
|
34
34
|
decoder, method_name = @decoder_options
|
|
35
35
|
|
|
36
|
-
decoder.public_send(method_name, body, @parser_options || {})
|
|
36
|
+
decoder.public_send(method_name, body, **(@parser_options || {}))
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def parse_response?(env)
|
data/lib/faraday/version.rb
CHANGED
data/lib/faraday.rb
CHANGED
|
@@ -137,6 +137,38 @@ module Faraday
|
|
|
137
137
|
@default_connection_options = ConnectionOptions.from(options)
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
+
# HTTP verb methods, forwarded to {.default_connection}.
|
|
141
|
+
#
|
|
142
|
+
# They take the same arguments as their {Faraday::Connection} counterparts,
|
|
143
|
+
# see {Faraday::Connection#get} and {Faraday::Connection#post}.
|
|
144
|
+
# Defining them here rather than relying on {method_missing} keeps them
|
|
145
|
+
# visible to `Faraday.methods`, `pry`'s `ls`, documentation tools and
|
|
146
|
+
# editor autocomplete.
|
|
147
|
+
|
|
148
|
+
# @!visibility private
|
|
149
|
+
METHODS_WITH_QUERY.each do |method|
|
|
150
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
|
151
|
+
# def get(url = nil, params = nil, headers = nil, &block)
|
|
152
|
+
# default_connection.get(url, params, headers, &block)
|
|
153
|
+
# end
|
|
154
|
+
def #{method}(url = nil, params = nil, headers = nil, &block)
|
|
155
|
+
default_connection.#{method}(url, params, headers, &block)
|
|
156
|
+
end
|
|
157
|
+
RUBY
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# @!visibility private
|
|
161
|
+
METHODS_WITH_BODY.each do |method|
|
|
162
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
|
163
|
+
# def post(url = nil, body = nil, headers = nil, &block)
|
|
164
|
+
# default_connection.post(url, body, headers, &block)
|
|
165
|
+
# end
|
|
166
|
+
def #{method}(url = nil, body = nil, headers = nil, &block)
|
|
167
|
+
default_connection.#{method}(url, body, headers, &block)
|
|
168
|
+
end
|
|
169
|
+
RUBY
|
|
170
|
+
end
|
|
171
|
+
|
|
140
172
|
private
|
|
141
173
|
|
|
142
174
|
# Internal: Proxies method calls on the Faraday constant to
|
data/spec/faraday_spec.rb
CHANGED
|
@@ -40,4 +40,30 @@ RSpec.describe Faraday do
|
|
|
40
40
|
Faraday.default_connection = nil
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
context 'HTTP verb methods' do
|
|
45
|
+
let(:mock_connection) { double('Connection') }
|
|
46
|
+
|
|
47
|
+
before do
|
|
48
|
+
Faraday.default_connection = mock_connection
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
(Faraday::METHODS_WITH_QUERY + Faraday::METHODS_WITH_BODY).each do |http_method|
|
|
52
|
+
it "defines .#{http_method} and forwards it to the default_connection" do
|
|
53
|
+
expect(Faraday.singleton_class.instance_methods(false)).to include(http_method.to_sym)
|
|
54
|
+
|
|
55
|
+
block = proc { |request| request }
|
|
56
|
+
expect(mock_connection).to receive(http_method) do |*args, &blk|
|
|
57
|
+
expect(args).to eq(['/foo', { page: 1 }, { 'X-Custom' => 'yes' }])
|
|
58
|
+
expect(blk).to be(block)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Faraday.public_send(http_method, '/foo', { page: 1 }, { 'X-Custom' => 'yes' }, &block)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
after do
|
|
66
|
+
Faraday.default_connection = nil
|
|
67
|
+
end
|
|
68
|
+
end
|
|
43
69
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -24,9 +24,18 @@ WebMock.disable_net_connect!(allow_localhost: true)
|
|
|
24
24
|
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
|
|
25
25
|
|
|
26
26
|
SimpleCov.start do
|
|
27
|
-
add_filter '/spec/'
|
|
28
27
|
minimum_coverage 84
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
# SimpleCov 1.0 first, then older.
|
|
30
|
+
if SimpleCov.respond_to?(:skip)
|
|
31
|
+
skip '/spec/'
|
|
32
|
+
skip '/tmp/'
|
|
33
|
+
coverage(:line) { minimum 26, per: :file }
|
|
34
|
+
else
|
|
35
|
+
add_filter '/spec/'
|
|
36
|
+
add_filter '/tmp/'
|
|
37
|
+
minimum_coverage_by_file 26
|
|
38
|
+
end
|
|
30
39
|
end
|
|
31
40
|
|
|
32
41
|
require 'faraday'
|
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.14.
|
|
4
|
+
version: 2.14.4
|
|
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.14.
|
|
147
|
+
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.14.4
|
|
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'
|