excon 0.110.0 → 0.111.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: 02c669c6654fe1baab80a1a55bc0a2d2b40a64360f3d95d77ef79b59315f879a
4
- data.tar.gz: '0759c4b45586f33258913b23ffb9b649cf40848816537f57763be8922ecc2b0b'
3
+ metadata.gz: '09b9d8be1f0954461960791f025122147f57ac828e24adb25cd63b7f0d520a4d'
4
+ data.tar.gz: 55f4fd066a2afdac2aecde07b7d91f3e564a89a5d0680e967a5227ca8171eafc
5
5
  SHA512:
6
- metadata.gz: 1d25f9b6551303983b04114bf9fa2d27e7a3ad06bcfa8cc2295fe8b8afd04142f103ce02d4969b7f06af5c10465c343921a12543dd348787a348b9ca150f30c9
7
- data.tar.gz: 3db2e11eae51f277b7a22ab3daa2505ea836098f6789001e580354f29706e5b6f1cd063cbab772ac6811186f0a8af955dd26029a17b15ea5a5b79d14285ba7b6
6
+ metadata.gz: 33469a58ddb269ffe4cf35066ec7c2e87921aacd49a4766ae85fbe7bdc0d7f1b26ee287838cd07ff322d008327c7ef7edf8cda0015a7a48a1b6a9c6537a4df1e
7
+ data.tar.gz: 65e294c562e75540e33f5555060289afeafb84024acbedc482d5efa526136605f45612972576ebc1612f3483d65290134a65709bcdd8ec3dfefdab015b62e556
data/data/cacert.pem CHANGED
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## Bundle of CA Root Certificates
3
3
  ##
4
- ## Certificate data from Mozilla as of: Mon Mar 11 15:25:27 2024 GMT
4
+ ## Certificate data from Mozilla as of: Tue Jul 2 03:12:04 2024 GMT
5
5
  ##
6
6
  ## This is a bundle of X.509 certificates of public Certificate Authorities
7
7
  ## (CA). These were automatically extracted from Mozilla's root certificates
@@ -14,7 +14,7 @@
14
14
  ## Just configure this file as the SSLCACertificateFile.
15
15
  ##
16
16
  ## Conversion done with mk-ca-bundle.pl version 1.29.
17
- ## SHA256: 4d96bd539f4719e9ace493757afbe4a23ee8579de1c97fbebc50bba3c12e8c1e
17
+ ## SHA256: 456ff095dde6dd73354c5c28c73d9c06f53b61a803963414cb91a1d92945cdd3
18
18
  ##
19
19
 
20
20
 
@@ -2600,36 +2600,6 @@ vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+
2600
2600
  CAezNIm8BZ/3Hobui3A=
2601
2601
  -----END CERTIFICATE-----
2602
2602
 
2603
- GLOBALTRUST 2020
2604
- ================
2605
- -----BEGIN CERTIFICATE-----
2606
- MIIFgjCCA2qgAwIBAgILWku9WvtPilv6ZeUwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCQVQx
2607
- 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
- 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
- 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
- MDIwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAri5WrRsc7/aVj6B3GyvTY4+ETUWi
2611
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- VC/f7GLDw56KoDEoqoOOpFaWEhCGVrqXctJUMHytGdUdaG/7FELYjQ7ztdGl4wJCXtzoRlgHNQIw
2623
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
2631
- -----END CERTIFICATE-----
2632
-
2633
2603
  ANF Secure Server Root CA
2634
2604
  =========================
2635
2605
  -----BEGIN CERTIFICATE-----
@@ -3579,3 +3549,20 @@ wPfc5+pbrrLMtTWGS9DiP7bY+A4A7l3j941Y/8+LN+ljX273CXE2whJdV/LItM3z7gLfEdxquVeE
3579
3549
  HVlNjM7IDiPCtyaaEBRx/pOyiriA8A4QntOoUAw3gi/q4Iqd4Sw5/7W0cwDk90imc6y/st53BIe0
3580
3550
  o82bNSQ3+pCTE4FCxpgmdTdmQRCsu/WU48IxK63nI1bMNSWSs1A=
3581
3551
  -----END CERTIFICATE-----
3552
+
3553
+ FIRMAPROFESIONAL CA ROOT-A WEB
3554
+ ==============================
3555
+ -----BEGIN CERTIFICATE-----
3556
+ MIICejCCAgCgAwIBAgIQMZch7a+JQn81QYehZ1ZMbTAKBggqhkjOPQQDAzBuMQswCQYDVQQGEwJF
3557
+ UzEcMBoGA1UECgwTRmlybWFwcm9mZXNpb25hbCBTQTEYMBYGA1UEYQwPVkFURVMtQTYyNjM0MDY4
3558
+ MScwJQYDVQQDDB5GSVJNQVBST0ZFU0lPTkFMIENBIFJPT1QtQSBXRUIwHhcNMjIwNDA2MDkwMTM2
3559
+ WhcNNDcwMzMxMDkwMTM2WjBuMQswCQYDVQQGEwJFUzEcMBoGA1UECgwTRmlybWFwcm9mZXNpb25h
3560
+ bCBTQTEYMBYGA1UEYQwPVkFURVMtQTYyNjM0MDY4MScwJQYDVQQDDB5GSVJNQVBST0ZFU0lPTkFM
3561
+ IENBIFJPT1QtQSBXRUIwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAARHU+osEaR3xyrq89Zfe9MEkVz6
3562
+ iMYiuYMQYneEMy3pA4jU4DP37XcsSmDq5G+tbbT4TIqk5B/K6k84Si6CcyvHZpsKjECcfIr28jlg
3563
+ st7L7Ljkb+qbXbdTkBgyVcUgt5SjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUk+FD
3564
+ Y1w8ndYn81LsF7Kpryz3dvgwHQYDVR0OBBYEFJPhQ2NcPJ3WJ/NS7Beyqa8s93b4MA4GA1UdDwEB
3565
+ /wQEAwIBBjAKBggqhkjOPQQDAwNoADBlAjAdfKR7w4l1M+E7qUW/Runpod3JIha3RxEL2Jq68cgL
3566
+ cFBTApFwhVmpHqTm6iMxoAACMQD94vizrxa5HnPEluPBMBnYfubDl94cT7iJLzPrSA8Z94dGXSaQ
3567
+ pYXFuXqUPoeovQA=
3568
+ -----END CERTIFICATE-----
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'ipaddr'
3
2
 
4
3
  module Excon
5
4
  class Connection
@@ -1,16 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
  module Excon
3
-
4
3
  CR_NL = "\r\n"
5
4
 
6
- DEFAULT_CA_FILE = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "data", "cacert.pem"))
5
+ DEFAULT_CA_FILE = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data', 'cacert.pem'))
7
6
 
8
- DEFAULT_CHUNK_SIZE = 1048576 # 1 megabyte
7
+ DEFAULT_CHUNK_SIZE = 1_048_576 # 1 megabyte
9
8
 
10
9
  # avoid overwrite if somebody has redefined
11
- unless const_defined?(:CHUNK_SIZE)
12
- CHUNK_SIZE = DEFAULT_CHUNK_SIZE
13
- end
10
+ CHUNK_SIZE = DEFAULT_CHUNK_SIZE unless const_defined?(:CHUNK_SIZE)
14
11
 
15
12
  DEFAULT_REDIRECT_LIMIT = 10
16
13
 
@@ -20,13 +17,13 @@ module Excon
20
17
  Excon::Error::Timeout,
21
18
  Excon::Error::Socket,
22
19
  Excon::Error::HTTPStatus
23
- ]
20
+ ].freeze
24
21
 
25
22
  FORCE_ENC = CR_NL.respond_to?(:force_encoding)
26
23
 
27
24
  HTTP_1_1 = " HTTP/1.1\r\n"
28
25
 
29
- HTTP_VERBS = %w{connect delete get head options patch post put trace}
26
+ HTTP_VERBS = %w[connect delete get head options patch post put trace].freeze
30
27
 
31
28
  HTTPS = 'https'
32
29
 
@@ -40,89 +37,89 @@ module Excon
40
37
 
41
38
  VERSIONS = "#{USER_AGENT} (#{RUBY_PLATFORM}) ruby/#{RUBY_VERSION}"
42
39
 
43
- VALID_REQUEST_KEYS = [
44
- :allow_unstubbed_requests,
45
- :body,
46
- :chunk_size,
47
- :debug_request,
48
- :debug_response,
49
- :dns_timeouts,
50
- :headers,
51
- :instrumentor, # Used for setting logging within Connection
52
- :logger,
53
- :method,
54
- :middlewares,
55
- :password,
56
- :path,
57
- :persistent,
58
- :pipeline,
59
- :query,
60
- :read_timeout,
61
- :request_block,
62
- :resolv_resolver,
63
- :response_block,
64
- :stubs,
65
- :timeout,
66
- :user,
67
- :versions,
68
- :write_timeout
69
- ]
70
-
71
- VALID_CONNECTION_KEYS = VALID_REQUEST_KEYS + [
72
- :ciphers,
73
- :client_key,
74
- :client_key_data,
75
- :client_key_pass,
76
- :client_cert,
77
- :client_cert_data,
78
- :client_chain,
79
- :client_chain_data,
80
- :certificate,
81
- :certificate_path,
82
- :disable_proxy,
83
- :private_key,
84
- :private_key_path,
85
- :connect_timeout,
86
- :family,
87
- :keepalive,
88
- :host,
89
- :hostname,
90
- :omit_default_port,
91
- :nonblock,
92
- :reuseaddr,
93
- :port,
94
- :proxy,
95
- :scheme,
96
- :socket,
97
- :ssl_ca_file,
98
- :ssl_ca_path,
99
- :ssl_cert_store,
100
- :ssl_verify_callback,
101
- :ssl_verify_peer,
102
- :ssl_verify_peer_host,
103
- :ssl_verify_hostname,
104
- :ssl_version,
105
- :ssl_min_version,
106
- :ssl_max_version,
107
- :ssl_security_level,
108
- :ssl_proxy_headers,
109
- :ssl_uri_schemes,
110
- :tcp_nodelay,
111
- :thread_safe_sockets,
112
- :uri_parser,
40
+ VALID_REQUEST_KEYS = %i[
41
+ allow_unstubbed_requests
42
+ body
43
+ chunk_size
44
+ debug_request
45
+ debug_response
46
+ dns_timeouts
47
+ headers
48
+ instrumentor
49
+ logger
50
+ method
51
+ middlewares
52
+ password
53
+ path
54
+ persistent
55
+ pipeline
56
+ query
57
+ read_timeout
58
+ request_block
59
+ resolv_resolver
60
+ response_block
61
+ stubs
62
+ timeout
63
+ user
64
+ versions
65
+ write_timeout
66
+ ].freeze
67
+
68
+ VALID_CONNECTION_KEYS = VALID_REQUEST_KEYS + %i[
69
+ ciphers
70
+ client_key
71
+ client_key_data
72
+ client_key_pass
73
+ client_cert
74
+ client_cert_data
75
+ client_chain
76
+ client_chain_data
77
+ certificate
78
+ certificate_path
79
+ disable_proxy
80
+ private_key
81
+ private_key_path
82
+ connect_timeout
83
+ family
84
+ keepalive
85
+ host
86
+ hostname
87
+ omit_default_port
88
+ nonblock
89
+ reuseaddr
90
+ port
91
+ proxy
92
+ scheme
93
+ socket
94
+ ssl_ca_file
95
+ ssl_ca_path
96
+ ssl_cert_store
97
+ ssl_verify_callback
98
+ ssl_verify_peer
99
+ ssl_verify_peer_host
100
+ ssl_verify_hostname
101
+ ssl_version
102
+ ssl_min_version
103
+ ssl_max_version
104
+ ssl_security_level
105
+ ssl_proxy_headers
106
+ ssl_uri_schemes
107
+ tcp_nodelay
108
+ thread_safe_sockets
109
+ uri_parser
113
110
  ]
114
111
 
115
112
  DEPRECATED_VALID_REQUEST_KEYS = {
116
- :captures => 'Mock',
117
- :expects => 'Expects',
118
- :idempotent => 'Idempotent',
119
- :instrumentor_name => 'Instrumentor',
120
- :mock => 'Mock',
121
- :retries_remaining => 'Idempotent', # referenced in Instrumentor, but only relevant with Idempotent
122
- :retry_errors => 'Idempotent',
123
- :retry_interval => 'Idempotent',
124
- :retry_limit => 'Idempotent' # referenced in Instrumentor, but only relevant with Idempotent
125
- }
113
+ captures: 'Mock',
114
+ expects: 'Expects',
115
+ idempotent: 'Idempotent',
116
+ instrumentor_name: 'Instrumentor',
117
+ mock: 'Mock',
118
+ retries_remaining: 'Idempotent', # referenced in Instrumentor, but only relevant with Idempotent
119
+ retry_errors: 'Idempotent',
120
+ retry_interval: 'Idempotent',
121
+ retry_limit: 'Idempotent' # referenced in Instrumentor, but only relevant with Idempotent
122
+ }.freeze
126
123
 
127
124
  unless ::IO.const_defined?(:WaitReadable)
128
125
  class ::IO
@@ -135,47 +132,46 @@ module Excon
135
132
  module WaitWritable; end
136
133
  end
137
134
  end
135
+
138
136
  # these come last as they rely on the above
139
137
  DEFAULTS = {
140
- :chunk_size => CHUNK_SIZE || DEFAULT_CHUNK_SIZE,
138
+ chunk_size: CHUNK_SIZE || DEFAULT_CHUNK_SIZE,
141
139
  # see https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28default.29
142
140
  # list provided then had DES related things sorted to the end
143
- :ciphers => 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!DSS',
144
- :connect_timeout => 60,
145
- :debug_request => false,
146
- :debug_response => false,
147
- :dns_timeouts => nil,
148
- # nil allows Resolv::DNS to set its default timeouts value (see https://ruby-doc.org/3.2.2/stdlibs/resolv/Resolv/DNS.html#method-i-timeouts-3D)
149
- :headers => {
141
+ ciphers: 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!DSS',
142
+ connect_timeout: 60,
143
+ debug_request: false,
144
+ debug_response: false,
145
+ dns_timeouts: nil, # nil allows Resolv::DNS default timeout value (see https://ruby-doc.org/3.2.2/stdlibs/resolv/Resolv/DNS.html#method-i-timeouts-3D)
146
+ headers: {
150
147
  'User-Agent' => USER_AGENT,
151
- 'Accept' => '*/*'
148
+ 'Accept' => '*/*'
152
149
  },
153
- :idempotent => false,
154
- :instrumentor_name => 'excon',
155
- :middlewares => [
150
+ idempotent: false,
151
+ instrumentor_name: 'excon',
152
+ middlewares: [
156
153
  Excon::Middleware::ResponseParser,
157
154
  Excon::Middleware::Expects,
158
155
  Excon::Middleware::Idempotent,
159
156
  Excon::Middleware::Instrumentor,
160
157
  Excon::Middleware::Mock
161
158
  ],
162
- :mock => false,
163
- :nonblock => true,
164
- :omit_default_port => false,
165
- :persistent => false,
166
- :read_timeout => 60,
167
- :resolv_resolver => nil,
168
- :retry_errors => DEFAULT_RETRY_ERRORS,
169
- :retry_limit => DEFAULT_RETRY_LIMIT,
170
- :ssl_verify_peer => true,
171
- :ssl_uri_schemes => [HTTPS],
172
- :stubs => :global,
173
- :tcp_nodelay => false,
174
- :thread_safe_sockets => true,
175
- :timeout => nil,
176
- :uri_parser => URI,
177
- :versions => VERSIONS,
178
- :write_timeout => 60
159
+ mock: false,
160
+ nonblock: true,
161
+ omit_default_port: false,
162
+ persistent: false,
163
+ read_timeout: 60,
164
+ resolv_resolver: nil,
165
+ retry_errors: DEFAULT_RETRY_ERRORS,
166
+ retry_limit: DEFAULT_RETRY_LIMIT,
167
+ ssl_verify_peer: true,
168
+ ssl_uri_schemes: [HTTPS],
169
+ stubs: :global,
170
+ tcp_nodelay: false,
171
+ thread_safe_sockets: true,
172
+ timeout: nil,
173
+ uri_parser: URI,
174
+ versions: VERSIONS,
175
+ write_timeout: 60
179
176
  }
180
-
181
177
  end
data/lib/excon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Excon
4
- VERSION = '0.110.0'
4
+ VERSION = '0.111.0'
5
5
  end
data/lib/excon.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  $:.unshift(File.dirname(__FILE__)) unless
3
4
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
4
5
 
5
6
  require 'cgi'
6
7
  require 'forwardable'
8
+ require 'ipaddr'
7
9
  require 'openssl'
8
10
  require 'rbconfig'
9
11
  require 'socket'
@@ -44,7 +46,6 @@ require 'excon/unix_socket'
44
46
  # Define defaults first so they will be available to other files
45
47
  module Excon
46
48
  class << self
47
-
48
49
  # @return [Hash] defaults for Excon connections
49
50
  def defaults
50
51
  @defaults ||= DEFAULTS
@@ -52,19 +53,15 @@ module Excon
52
53
 
53
54
  # Change defaults for Excon connections
54
55
  # @return [Hash] defaults for Excon connections
55
- def defaults=(new_defaults)
56
- @defaults = new_defaults
57
- end
56
+ attr_writer :defaults
58
57
 
59
58
  def display_warning(warning)
60
59
  # Show warning if $VERBOSE or ENV['EXCON_DEBUG'] is set
61
- if $VERBOSE || ENV['EXCON_DEBUG']
62
- $stderr.puts "[excon][WARNING] #{warning}\n#{ caller.join("\n") }"
63
- end
60
+ ($VERBOSE || ENV['EXCON_DEBUG']) && Warning.warn("[excon][WARNING] #{warning}\n#{caller.join("\n")}")
64
61
 
65
- if @raise_on_warnings
66
- raise Error::Warning.new(warning)
67
- end
62
+ return unless @raise_on_warnings
63
+
64
+ raise(Error::Warning, warning)
68
65
  end
69
66
 
70
67
  def set_raise_on_warnings!(should_raise)
@@ -119,32 +116,25 @@ module Excon
119
116
  def new(url, params = {})
120
117
  uri_parser = params[:uri_parser] || defaults[:uri_parser]
121
118
  uri = uri_parser.parse(url)
122
- if params[:path]
123
- uri_parser.parse(params[:path])
124
- end
125
- unless uri.scheme
126
- raise ArgumentError.new("Invalid URI: #{uri}")
127
- end
119
+ params[:path] && uri_parser.parse(params[:path])
120
+ raise(ArgumentError, "Invalid URI: #{uri}") unless uri.scheme
121
+
128
122
  params = {
129
- :host => uri.host,
130
- :hostname => uri.hostname,
131
- :path => uri.path,
132
- :port => uri.port,
133
- :query => uri.query,
134
- :scheme => uri.scheme
123
+ host: uri.host,
124
+ hostname: uri.hostname,
125
+ path: uri.path,
126
+ port: uri.port,
127
+ query: uri.query,
128
+ scheme: uri.scheme
135
129
  }.merge(params)
136
- if uri.password
137
- params[:password] = Utils.unescape_uri(uri.password)
138
- end
139
- if uri.user
140
- params[:user] = Utils.unescape_uri(uri.user)
141
- end
130
+ uri.password && params[:password] = Utils.unescape_uri(uri.password)
131
+ uri.user && params[:user] = Utils.unescape_uri(uri.user)
142
132
  Excon::Connection.new(params)
143
133
  end
144
134
 
145
135
  # push an additional stub onto the list to check for mock requests
146
136
  # @param request_params [Hash<Symbol, >] request params to match against, omitted params match all
147
- # @param response_params [Hash<Symbol, >] response params to return from matched request or block to call with params
137
+ # @param response_params [Hash<Symbol, >] response params to return or block to call with matched params
148
138
  def stub(request_params = {}, response_params = nil, &block)
149
139
  if (method = request_params.delete(:method))
150
140
  request_params[:method] = method.to_s.downcase.to_sym
@@ -152,19 +142,20 @@ module Excon
152
142
  if (url = request_params.delete(:url))
153
143
  uri = URI.parse(url)
154
144
  request_params = {
155
- :host => uri.host,
156
- :path => uri.path,
157
- :port => uri.port,
158
- :query => uri.query,
159
- :scheme => uri.scheme
145
+ host: uri.host,
146
+ path: uri.path,
147
+ port: uri.port,
148
+ query: uri.query,
149
+ scheme: uri.scheme
160
150
  }.merge!(request_params)
161
151
  if uri.user || uri.password
162
152
  request_params[:headers] ||= {}
163
- user, pass = Utils.unescape_form(uri.user.to_s), Utils.unescape_form(uri.password.to_s)
153
+ user = Utils.unescape_form(uri.user.to_s)
154
+ pass = Utils.unescape_form(uri.password.to_s)
164
155
  request_params[:headers]['Authorization'] ||= 'Basic ' + ["#{user}:#{pass}"].pack('m').delete(Excon::CR_NL)
165
156
  end
166
157
  end
167
- if request_params.has_key?(:headers)
158
+ if request_params.key?(:headers)
168
159
  headers = Excon::Headers.new
169
160
  request_params[:headers].each do |key, value|
170
161
  headers[key] = value
@@ -172,15 +163,13 @@ module Excon
172
163
  request_params[:headers] = headers
173
164
  end
174
165
  if block_given?
175
- if response_params
176
- raise(ArgumentError.new("stub requires either response_params OR a block"))
177
- else
178
- stub = [request_params, block]
179
- end
166
+ raise(ArgumentError, 'stub requires either response_params OR a block') if response_params
167
+
168
+ stub = [request_params, block]
180
169
  elsif response_params
181
170
  stub = [request_params, response_params]
182
171
  else
183
- raise(ArgumentError.new("stub requires either response_params OR a block"))
172
+ raise(ArgumentError, 'stub requires either response_params OR a block')
184
173
  end
185
174
  stubs.unshift(stub)
186
175
  stub
@@ -194,8 +183,8 @@ module Excon
194
183
  request_params[:method] = method.to_s.downcase.to_sym
195
184
  end
196
185
  Excon.stubs.each do |stub, response_params|
197
- captures = { :headers => {} }
198
- headers_match = !stub.has_key?(:headers) || stub[:headers].keys.all? do |key|
186
+ captures = { headers: {} }
187
+ headers_match = !stub.key?(:headers) || stub[:headers].keys.all? do |key|
199
188
  case value = stub[:headers][key]
200
189
  when Regexp
201
190
  case request_params[:headers][key]
@@ -249,9 +238,9 @@ module Excon
249
238
  # @param request_params [Hash<Symbol, >] request params to match against, omitted params match all
250
239
  # @return [Hash<Symbol, >] response params from deleted stub
251
240
  def unstub(request_params = {})
252
- if (stub = stub_for(request_params))
253
- Excon.stubs.delete_at(Excon.stubs.index(stub))
254
- end
241
+ return unless (stub = stub_for(request_params))
242
+
243
+ Excon.stubs.delete_at(Excon.stubs.index(stub))
255
244
  end
256
245
 
257
246
  # Generic non-persistent HTTP methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.110.0
4
+ version: 0.111.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dpiddy (Dan Peterson)
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-03-12 00:00:00.000000000 Z
13
+ date: 2024-07-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -251,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
251
  - !ruby/object:Gem::Version
252
252
  version: '0'
253
253
  requirements: []
254
- rubygems_version: 3.4.22
254
+ rubygems_version: 3.4.10
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: speed, persistence, http(s)