faraday 2.7.4 → 2.9.0

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: acdabcdd0a13d304292f17cd6764fba01d12f552cf78bdae3006ee38a3921ad0
4
- data.tar.gz: 13300a1971d6557a4c62f01c4b0c96d1aecb4372b4c8a1ba734022109d9f2c0b
3
+ metadata.gz: 8daafc733cd0bf7b27c3ec39dcca14da1dd4ad6bf28d72e96c6c7c214d4992e1
4
+ data.tar.gz: 8b5ce62606f14fd89a64adbe24099ef53067c98444419bfe58b0b986501dae5d
5
5
  SHA512:
6
- metadata.gz: 0151023e942ae76b69a6bb28e70c792501333bc4f67c670bb990e80917c6b4d63aaa9ee168bd333abff2dd2b1fb54f244568e7a54d5346034d311924b17eabfe
7
- data.tar.gz: 9598f16ed0c19cdfe01be90a1a29e6751b6848d44eac1d481224fbe576a33ff73f631a2bd398f70b5534d4126f8dba9ced68bb17dad5ea8efe93214bf7ce4e1b
6
+ metadata.gz: 980d8a35587b2ead1383ac7cd7f8649c193a6d9685c0d69c97f9be4937a18deeef7858d50d2c20649774ac97293d0dc6d4b51049cb40e4f4422132d0c58f372b
7
+ data.tar.gz: a02dbd0bd5d2670728f39f2a673b385abda43d7449cb204bff10878e562a179c2de595665096dbc24c4d183990a0417c7386159afb952955806c0ea3321bf5fe
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,20 +6,36 @@
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
- Need more details? See the [Faraday API Documentation][apidoc] to see how it works internally.
30
+
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) 🚀
16
32
 
17
33
  ## Supported Ruby versions
18
34
 
19
35
  This library aims to support and is [tested against][actions] the currently officially supported Ruby
20
36
  implementations. This means that, even without a major release, we could add or drop support for Ruby versions,
21
37
  following their [EOL](https://endoflife.date/ruby).
22
- Currently that means we support Ruby 2.6+
38
+ Currently that means we support Ruby 3.0+
23
39
 
24
40
  If something doesn't work on one of these Ruby versions, it's a bug.
25
41
 
@@ -42,14 +58,10 @@ But before you start coding, please read our [Contributing Guide][contributing]
42
58
 
43
59
  ## Copyright
44
60
 
45
- © 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).
46
62
 
47
63
  [awesome]: https://github.com/lostisland/awesome-faraday/#adapters
48
64
  [website]: https://lostisland.github.io/faraday
49
- [faraday_team]: https://lostisland.github.io/faraday/team
50
- [contributing]: https://github.com/lostisland/faraday/blob/master/.github/CONTRIBUTING.md
65
+ [contributing]: https://github.com/lostisland/faraday/blob/main/.github/CONTRIBUTING.md
51
66
  [apidoc]: https://www.rubydoc.info/github/lostisland/faraday
52
67
  [actions]: https://github.com/lostisland/faraday/actions
53
- [jruby]: http://jruby.org/
54
- [rubinius]: http://rubini.us/
55
- [license]: LICENSE.md
data/Rakefile CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'rspec/core/rake_task'
4
4
 
5
- RSpec::Core::RakeTask.new(:spec)
5
+ RSpec::Core::RakeTask.new(:spec) do |task|
6
+ task.ruby_opts = %w[-W]
7
+ end
6
8
 
7
9
  task default: :spec
@@ -146,7 +146,7 @@ module Faraday
146
146
  # which means that all of a path, parameters, and headers must be the same as an actual request.
147
147
  def strict_mode=(value)
148
148
  @strict_mode = value
149
- @stack.each do |_method, stubs|
149
+ @stack.each_value do |stubs|
150
150
  stubs.each do |stub|
151
151
  stub.strict_mode = value
152
152
  end
@@ -184,7 +184,7 @@ module Faraday
184
184
  end
185
185
 
186
186
  # Stub request
187
- class Stub < Struct.new(:host, :path, :query, :headers, :body, :strict_mode, :block) # rubocop:disable Style/StructInheritance
187
+ Stub = Struct.new(:host, :path, :query, :headers, :body, :strict_mode, :block) do
188
188
  # @param env [Faraday::Env]
189
189
  def matches?(env)
190
190
  request_host = env[:url].host
@@ -275,7 +275,7 @@ module Faraday
275
275
 
276
276
  unless stub
277
277
  raise Stubs::NotFound, "no stubbed request for #{env[:method]} " \
278
- "#{env[:url]} #{env[:body]}"
278
+ "#{env[:url]} #{env[:body]} #{env[:headers]}"
279
279
  end
280
280
 
281
281
  block_arity = stub.block.arity
@@ -15,7 +15,7 @@ module Faraday
15
15
  class Connection
16
16
  # A Set of allowed HTTP verbs.
17
17
  METHODS = Set.new %i[get post put delete head patch options trace]
18
- USER_AGENT = "Faraday v#{VERSION}"
18
+ USER_AGENT = "Faraday v#{VERSION}".freeze
19
19
 
20
20
  # @return [Hash] URI query unencoded key/value pairs.
21
21
  attr_reader :params
@@ -514,22 +514,17 @@ module Faraday
514
514
  return if Faraday.ignore_env_proxy
515
515
 
516
516
  uri = nil
517
- if URI.parse('').respond_to?(:find_proxy)
518
- case url
519
- when String
520
- uri = Utils.URI(url)
521
- uri = if uri.host.nil?
522
- find_default_proxy
523
- else
524
- URI.parse("#{uri.scheme}://#{uri.host}").find_proxy
525
- end
526
- when URI
527
- uri = url.find_proxy
528
- when nil
529
- uri = find_default_proxy
530
- end
531
- else
532
- warn 'no_proxy is unsupported' if ENV['no_proxy'] || ENV['NO_PROXY']
517
+ case url
518
+ when String
519
+ uri = Utils.URI(url)
520
+ uri = if uri.host.nil?
521
+ find_default_proxy
522
+ else
523
+ URI.parse("#{uri.scheme}://#{uri.host}").find_proxy
524
+ end
525
+ when URI
526
+ uri = url.find_proxy
527
+ when nil
533
528
  uri = find_default_proxy
534
529
  end
535
530
  ProxyOptions.from(uri) if uri
@@ -102,7 +102,7 @@ module Faraday
102
102
 
103
103
  protected
104
104
 
105
- SUBKEYS_REGEX = /[^\[\]]+(?:\]?\[\])?/.freeze
105
+ SUBKEYS_REGEX = /[^\[\]]+(?:\]?\[\])?/
106
106
 
107
107
  def decode_pair(key, value, context)
108
108
  subkeys = key.scan(SUBKEYS_REGEX)
data/lib/faraday/error.rb CHANGED
@@ -29,15 +29,21 @@ module Faraday
29
29
  end
30
30
 
31
31
  def response_status
32
- @response[:status] if @response
32
+ return unless @response
33
+
34
+ @response.is_a?(Faraday::Response) ? @response.status : @response[:status]
33
35
  end
34
36
 
35
37
  def response_headers
36
- @response[:headers] if @response
38
+ return unless @response
39
+
40
+ @response.is_a?(Faraday::Response) ? @response.headers : @response[:headers]
37
41
  end
38
42
 
39
43
  def response_body
40
- @response[:body] if @response
44
+ return unless @response
45
+
46
+ @response.is_a?(Faraday::Response) ? @response.body : @response[:body]
41
47
  end
42
48
 
43
49
  protected
@@ -106,6 +112,10 @@ module Faraday
106
112
  class ProxyAuthError < ClientError
107
113
  end
108
114
 
115
+ # Raised by Faraday::Response::RaiseError in case of a 408 response.
116
+ class RequestTimeoutError < ClientError
117
+ end
118
+
109
119
  # Raised by Faraday::Response::RaiseError in case of a 409 response.
110
120
  class ConflictError < ClientError
111
121
  end
@@ -114,6 +124,10 @@ module Faraday
114
124
  class UnprocessableEntityError < ClientError
115
125
  end
116
126
 
127
+ # Raised by Faraday::Response::RaiseError in case of a 429 response.
128
+ class TooManyRequestsError < ClientError
129
+ end
130
+
117
131
  # Faraday server error class. Represents 5xx status responses.
118
132
  class ServerError < Error
119
133
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pp' # rubocop:disable Lint/RedundantRequireStatement
3
+ require 'pp' # This require is necessary for Hash#pretty_inspect to work, do not remove it, people rely on it.
4
4
 
5
5
  module Faraday
6
6
  module Logging
@@ -13,25 +13,26 @@ module Faraday
13
13
 
14
14
  def initialize(logger:, options:)
15
15
  @logger = logger
16
- @filter = []
17
16
  @options = DEFAULT_OPTIONS.merge(options)
17
+ unless %i[debug info warn error fatal].include?(@options[:log_level])
18
+ @options[:log_level] = :info
19
+ end
20
+ @filter = []
18
21
  end
19
22
 
20
23
  def_delegators :@logger, :debug, :info, :warn, :error, :fatal
21
24
 
22
25
  def request(env)
23
- request_log = proc do
26
+ public_send(log_level, 'request') do
24
27
  "#{env.method.upcase} #{apply_filters(env.url.to_s)}"
25
28
  end
26
- public_send(log_level, 'request', &request_log)
27
29
 
28
30
  log_headers('request', env.request_headers) if log_headers?(:request)
29
31
  log_body('request', env[:body]) if env[:body] && log_body?(:request)
30
32
  end
31
33
 
32
34
  def response(env)
33
- status = proc { "Status #{env.status}" }
34
- public_send(log_level, 'response', &status)
35
+ public_send(log_level, 'response') { "Status #{env.status}" }
35
36
 
36
37
  log_headers('response', env.response_headers) if log_headers?(:response)
37
38
  log_body('response', env[:body]) if env[:body] && log_body?(:response)
@@ -40,8 +41,7 @@ module Faraday
40
41
  def exception(exc)
41
42
  return unless log_errors?
42
43
 
43
- error_log = proc { exc.full_message }
44
- public_send(log_level, 'error', &error_log)
44
+ public_send(log_level, 'error') { exc.full_message }
45
45
 
46
46
  log_headers('error', exc.response_headers) if exc.respond_to?(:response_headers) && log_headers?(:error)
47
47
  return unless exc.respond_to?(:response_body) && exc.response_body && log_body?(:error)
@@ -56,6 +56,8 @@ module Faraday
56
56
  private
57
57
 
58
58
  def dump_headers(headers)
59
+ return if headers.nil?
60
+
59
61
  headers.map { |k, v| "#{k}: #{v.inspect}" }.join("\n")
60
62
  end
61
63
 
@@ -101,21 +103,15 @@ module Faraday
101
103
  end
102
104
 
103
105
  def log_level
104
- unless %i[debug info warn error fatal].include?(@options[:log_level])
105
- return :info
106
- end
107
-
108
106
  @options[:log_level]
109
107
  end
110
108
 
111
109
  def log_headers(type, headers)
112
- headers_log = proc { apply_filters(dump_headers(headers)) }
113
- public_send(log_level, type, &headers_log)
110
+ public_send(log_level, type) { apply_filters(dump_headers(headers)) }
114
111
  end
115
112
 
116
113
  def log_body(type, body)
117
- body_log = proc { apply_filters(dump_body(body)) }
118
- public_send(log_level, type, &body_log)
114
+ public_send(log_level, type) { apply_filters(dump_body(body)) }
119
115
  end
120
116
  end
121
117
  end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- # ConnectionOptions contains the configurable properties for a Faraday
5
- # connection object.
6
- class ConnectionOptions < Options.new(:request, :proxy, :ssl, :builder, :url,
7
- :parallel_manager, :params, :headers,
8
- :builder_class)
9
-
4
+ # @!parse
5
+ # # ConnectionOptions contains the configurable properties for a Faraday
6
+ # # connection object.
7
+ # class ConnectionOptions < Options; end
8
+ ConnectionOptions = Options.new(:request, :proxy, :ssl, :builder, :url,
9
+ :parallel_manager, :params, :headers,
10
+ :builder_class) do
10
11
  options request: RequestOptions, ssl: SSLOptions
11
12
 
12
13
  memoized(:request) { self.class.options_for(:request).new }
@@ -1,71 +1,70 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- # @!attribute method
5
- # @return [Symbol] HTTP method (`:get`, `:post`)
6
- #
7
- # @!attribute body
8
- # @return [String] The request body that will eventually be converted to a
9
- # string.
10
- #
11
- # @!attribute url
12
- # @return [URI] URI instance for the current request.
13
- #
14
- # @!attribute request
15
- # @return [Hash] options for configuring the request.
16
- # Options for configuring the request.
17
- #
18
- # - `:timeout` - time limit for the entire request (Integer in
19
- # seconds)
20
- # - `:open_timeout` - time limit for just the connection phase (e.g.
21
- # handshake) (Integer in seconds)
22
- # - `:read_timeout` - time limit for the first response byte received from
23
- # the server (Integer in seconds)
24
- # - `:write_timeout` - time limit for the client to send the request to the
25
- # server (Integer in seconds)
26
- # - `:on_data` - Proc for streaming
27
- # - `:proxy` - Hash of proxy options
28
- # - `:uri` - Proxy server URI
29
- # - `:user` - Proxy server username
30
- # - `:password` - Proxy server password
31
- #
32
- # @!attribute request_headers
33
- # @return [Hash] HTTP Headers to be sent to the server.
34
- #
35
- # @!attribute ssl
36
- # @return [Hash] options for configuring SSL requests
37
- #
38
- # @!attribute parallel_manager
39
- # @return [Object] sent if the connection is in parallel mode
40
- #
41
- # @!attribute params
42
- # @return [Hash]
43
- #
44
- # @!attribute response
45
- # @return [Response]
46
- #
47
- # @!attribute response_headers
48
- # @return [Hash] HTTP headers from the server
49
- #
50
- # @!attribute status
51
- # @return [Integer] HTTP response status code
52
- #
53
- # @!attribute reason_phrase
54
- # @return [String]
55
- class Env < Options.new(:method, :request_body, :url, :request,
56
- :request_headers, :ssl, :parallel_manager, :params,
57
- :response, :response_headers, :status,
58
- :reason_phrase, :response_body)
59
-
60
- # rubocop:disable Naming/ConstantName
61
- ContentLength = 'Content-Length'
62
- StatusesWithoutBody = Set.new [204, 304]
63
- SuccessfulStatuses = (200..299).freeze
64
- # rubocop:enable Naming/ConstantName
4
+ # @!parse
5
+ # # @!attribute method
6
+ # # @return [Symbol] HTTP method (`:get`, `:post`)
7
+ # #
8
+ # # @!attribute body
9
+ # # @return [String] The request body that will eventually be converted to a
10
+ # # string.
11
+ # #
12
+ # # @!attribute url
13
+ # # @return [URI] URI instance for the current request.
14
+ # #
15
+ # # @!attribute request
16
+ # # @return [Hash] options for configuring the request.
17
+ # # Options for configuring the request.
18
+ # #
19
+ # # - `:timeout` - time limit for the entire request (Integer in
20
+ # # seconds)
21
+ # # - `:open_timeout` - time limit for just the connection phase (e.g.
22
+ # # handshake) (Integer in seconds)
23
+ # # - `:read_timeout` - time limit for the first response byte received from
24
+ # # the server (Integer in seconds)
25
+ # # - `:write_timeout` - time limit for the client to send the request to the
26
+ # # server (Integer in seconds)
27
+ # # - `:on_data` - Proc for streaming
28
+ # # - `:proxy` - Hash of proxy options
29
+ # # - `:uri` - Proxy server URI
30
+ # # - `:user` - Proxy server username
31
+ # # - `:password` - Proxy server password
32
+ # #
33
+ # # @!attribute request_headers
34
+ # # @return [Hash] HTTP Headers to be sent to the server.
35
+ # #
36
+ # # @!attribute ssl
37
+ # # @return [Hash] options for configuring SSL requests
38
+ # #
39
+ # # @!attribute parallel_manager
40
+ # # @return [Object] sent if the connection is in parallel mode
41
+ # #
42
+ # # @!attribute params
43
+ # # @return [Hash]
44
+ # #
45
+ # # @!attribute response
46
+ # # @return [Response]
47
+ # #
48
+ # # @!attribute response_headers
49
+ # # @return [Hash] HTTP headers from the server
50
+ # #
51
+ # # @!attribute status
52
+ # # @return [Integer] HTTP response status code
53
+ # #
54
+ # # @!attribute reason_phrase
55
+ # # @return [String]
56
+ # class Env < Options; end
57
+ Env = Options.new(:method, :request_body, :url, :request,
58
+ :request_headers, :ssl, :parallel_manager, :params,
59
+ :response, :response_headers, :status,
60
+ :reason_phrase, :response_body) do
61
+ const_set(:ContentLength, 'Content-Length')
62
+ const_set(:StatusesWithoutBody, Set.new([204, 304]))
63
+ const_set(:SuccessfulStatuses, (200..299))
65
64
 
66
65
  # A Set of HTTP verbs that typically send a body. If no body is set for
67
66
  # these requests, the Content-Length header is set to 0.
68
- MethodsWithBodies = Set.new(Faraday::METHODS_WITH_BODY.map(&:to_sym))
67
+ const_set(:MethodsWithBodies, Set.new(Faraday::METHODS_WITH_BODY.map(&:to_sym)))
69
68
 
70
69
  options request: RequestOptions,
71
70
  request_headers: Utils::Headers, response_headers: Utils::Headers
@@ -126,25 +125,25 @@ module Faraday
126
125
 
127
126
  # @return [Boolean] true if status is in the set of {SuccessfulStatuses}.
128
127
  def success?
129
- SuccessfulStatuses.include?(status)
128
+ Env::SuccessfulStatuses.include?(status)
130
129
  end
131
130
 
132
131
  # @return [Boolean] true if there's no body yet, and the method is in the
133
- # set of {MethodsWithBodies}.
132
+ # set of {Env::MethodsWithBodies}.
134
133
  def needs_body?
135
- !body && MethodsWithBodies.include?(method)
134
+ !body && Env::MethodsWithBodies.include?(method)
136
135
  end
137
136
 
138
137
  # Sets content length to zero and the body to the empty string.
139
138
  def clear_body
140
- request_headers[ContentLength] = '0'
139
+ request_headers[Env::ContentLength] = '0'
141
140
  self.body = +''
142
141
  end
143
142
 
144
143
  # @return [Boolean] true if the status isn't in the set of
145
- # {StatusesWithoutBody}.
144
+ # {Env::StatusesWithoutBody}.
146
145
  def parse_body?
147
- !StatusesWithoutBody.include?(status)
146
+ !Env::StatusesWithoutBody.include?(status)
148
147
  end
149
148
 
150
149
  # @return [Boolean] true if there is a parallel_manager
@@ -1,15 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- # ProxyOptions contains the configurable properties for the proxy
5
- # configuration used when making an HTTP request.
6
- class ProxyOptions < Options.new(:uri, :user, :password)
4
+ # @!parse
5
+ # # ProxyOptions contains the configurable properties for the proxy
6
+ # # configuration used when making an HTTP request.
7
+ # class ProxyOptions < Options; end
8
+ ProxyOptions = Options.new(:uri, :user, :password) do
7
9
  extend Forwardable
8
10
  def_delegators :uri, :scheme, :scheme=, :host, :host=, :port, :port=,
9
11
  :path, :path=
10
12
 
11
13
  def self.from(value)
12
14
  case value
15
+ when ''
16
+ value = nil
13
17
  when String
14
18
  # URIs without a scheme should default to http (like 'example:123').
15
19
  # This fixes #1282 and prevents a silent failure in some adapters.
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- # RequestOptions contains the configurable properties for a Faraday request.
5
- class RequestOptions < Options.new(:params_encoder, :proxy, :bind,
6
- :timeout, :open_timeout, :read_timeout,
7
- :write_timeout, :boundary, :oauth,
8
- :context, :on_data)
9
-
4
+ # @!parse
5
+ # # RequestOptions contains the configurable properties for a Faraday request.
6
+ # class RequestOptions < Options; end
7
+ RequestOptions = Options.new(:params_encoder, :proxy, :bind,
8
+ :timeout, :open_timeout, :read_timeout,
9
+ :write_timeout, :boundary, :oauth,
10
+ :context, :on_data) do
10
11
  def []=(key, value)
11
12
  if key && key.to_sym == :proxy
12
13
  super(key, value ? ProxyOptions.from(value) : nil)
@@ -1,56 +1,57 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- # SSL-related options.
5
- #
6
- # @!attribute verify
7
- # @return [Boolean] whether to verify SSL certificates or not
8
- #
9
- # @!attribute verify_hostname
10
- # @return [Boolean] whether to enable hostname verification on server certificates
11
- # during the handshake or not (see https://github.com/ruby/openssl/pull/60)
12
- #
13
- # @!attribute ca_file
14
- # @return [String] CA file
15
- #
16
- # @!attribute ca_path
17
- # @return [String] CA path
18
- #
19
- # @!attribute verify_mode
20
- # @return [Integer] Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
21
- #
22
- # @!attribute cert_store
23
- # @return [OpenSSL::X509::Store] certificate store
24
- #
25
- # @!attribute client_cert
26
- # @return [String, OpenSSL::X509::Certificate] client certificate
27
- #
28
- # @!attribute client_key
29
- # @return [String, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA] client key
30
- #
31
- # @!attribute certificate
32
- # @return [OpenSSL::X509::Certificate] certificate (Excon only)
33
- #
34
- # @!attribute private_key
35
- # @return [OpenSSL::PKey::RSA, OpenSSL::PKey::DSA] private key (Excon only)
36
- #
37
- # @!attribute verify_depth
38
- # @return [Integer] maximum depth for the certificate chain verification
39
- #
40
- # @!attribute version
41
- # @return [String, Symbol] SSL version (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html#method-i-ssl_version-3D)
42
- #
43
- # @!attribute min_version
44
- # @return [String, Symbol] minimum SSL version (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html#method-i-min_version-3D)
45
- #
46
- # @!attribute max_version
47
- # @return [String, Symbol] maximum SSL version (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html#method-i-max_version-3D)
48
- class SSLOptions < Options.new(:verify, :verify_hostname,
49
- :ca_file, :ca_path, :verify_mode,
50
- :cert_store, :client_cert, :client_key,
51
- :certificate, :private_key, :verify_depth,
52
- :version, :min_version, :max_version)
53
-
4
+ # @!parse
5
+ # # SSL-related options.
6
+ # #
7
+ # # @!attribute verify
8
+ # # @return [Boolean] whether to verify SSL certificates or not
9
+ # #
10
+ # # @!attribute verify_hostname
11
+ # # @return [Boolean] whether to enable hostname verification on server certificates
12
+ # # during the handshake or not (see https://github.com/ruby/openssl/pull/60)
13
+ # #
14
+ # # @!attribute ca_file
15
+ # # @return [String] CA file
16
+ # #
17
+ # # @!attribute ca_path
18
+ # # @return [String] CA path
19
+ # #
20
+ # # @!attribute verify_mode
21
+ # # @return [Integer] Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
22
+ # #
23
+ # # @!attribute cert_store
24
+ # # @return [OpenSSL::X509::Store] certificate store
25
+ # #
26
+ # # @!attribute client_cert
27
+ # # @return [String, OpenSSL::X509::Certificate] client certificate
28
+ # #
29
+ # # @!attribute client_key
30
+ # # @return [String, OpenSSL::PKey::RSA, OpenSSL::PKey::DSA] client key
31
+ # #
32
+ # # @!attribute certificate
33
+ # # @return [OpenSSL::X509::Certificate] certificate (Excon only)
34
+ # #
35
+ # # @!attribute private_key
36
+ # # @return [OpenSSL::PKey::RSA, OpenSSL::PKey::DSA] private key (Excon only)
37
+ # #
38
+ # # @!attribute verify_depth
39
+ # # @return [Integer] maximum depth for the certificate chain verification
40
+ # #
41
+ # # @!attribute version
42
+ # # @return [String, Symbol] SSL version (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html#method-i-ssl_version-3D)
43
+ # #
44
+ # # @!attribute min_version
45
+ # # @return [String, Symbol] minimum SSL version (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html#method-i-min_version-3D)
46
+ # #
47
+ # # @!attribute max_version
48
+ # # @return [String, Symbol] maximum SSL version (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html#method-i-max_version-3D)
49
+ # class SSLOptions < Options; end
50
+ SSLOptions = Options.new(:verify, :verify_hostname,
51
+ :ca_file, :ca_path, :verify_mode,
52
+ :cert_store, :client_cert, :client_key,
53
+ :certificate, :private_key, :verify_depth,
54
+ :version, :min_version, :max_version) do
54
55
  # @return [Boolean] true if should verify
55
56
  def verify?
56
57
  verify != false