excon 0.111.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/data/cacert.pem +100 -2
- data/lib/excon/connection.rb +6 -0
- data/lib/excon/constants.rb +8 -3
- data/lib/excon/middlewares/decompress.rb +17 -22
- data/lib/excon/ssl_socket.rb +1 -1
- data/lib/excon/utils.rb +25 -3
- data/lib/excon/version.rb +1 -1
- data/lib/excon.rb +8 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 955c2ed7f6ee55d4a279f386f6041f2d465640bd2c49930fcb213f0e63852e17
|
4
|
+
data.tar.gz: 49190e08fa385b6bd878096da5df9ad062c8e643477930e60916908581c1ef02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5fcebc27e76063b3be519a0eae585eabd4b3a40591fef96c1750cd7ddfcd9df940a760907f6f7717ab4628eb3f036640afe8da51312ec2741eb5eb8a13a612d
|
7
|
+
data.tar.gz: 10a234e21629066f1a6682c0c63a0f9bf60bd211ea13018ad5951c3012268e6826d88459d9bcee63518e2a3ccd1558dabb1fba03c9e7d450281d4ab7f8bc6c1a
|
data/README.md
CHANGED
@@ -190,6 +190,9 @@ connection.request(:timeout => 0.1) # timeout if the entire request takes longer
|
|
190
190
|
#
|
191
191
|
connection = Excon.new('http://geemus.com/', :tcp_nodelay => true)
|
192
192
|
|
193
|
+
# opt-in to having Excon add a default port (http:80 and https:443)
|
194
|
+
connection = Excon.new('http://geemus.com/', :include_default_port => true)
|
195
|
+
|
193
196
|
# set longer connect_timeout (default is 60 seconds)
|
194
197
|
connection = Excon.new('http://geemus.com/', :connect_timeout => 360)
|
195
198
|
|
data/data/cacert.pem
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
##
|
2
2
|
## Bundle of CA Root Certificates
|
3
3
|
##
|
4
|
-
## Certificate data from Mozilla as of: Tue
|
4
|
+
## Certificate data from Mozilla as of: Tue Sep 24 03:12:04 2024 GMT
|
5
|
+
##
|
6
|
+
## Find updated versions here: https://curl.se/docs/caextract.html
|
5
7
|
##
|
6
8
|
## This is a bundle of X.509 certificates of public Certificate Authorities
|
7
9
|
## (CA). These were automatically extracted from Mozilla's root certificates
|
@@ -14,7 +16,7 @@
|
|
14
16
|
## Just configure this file as the SSLCACertificateFile.
|
15
17
|
##
|
16
18
|
## Conversion done with mk-ca-bundle.pl version 1.29.
|
17
|
-
## SHA256:
|
19
|
+
## SHA256: 36105b01631f9fc03b1eca779b44a30a1a5890b9bf8dc07ccb001a07301e01cf
|
18
20
|
##
|
19
21
|
|
20
22
|
|
@@ -3566,3 +3568,99 @@ Y1w8ndYn81LsF7Kpryz3dvgwHQYDVR0OBBYEFJPhQ2NcPJ3WJ/NS7Beyqa8s93b4MA4GA1UdDwEB
|
|
3566
3568
|
cFBTApFwhVmpHqTm6iMxoAACMQD94vizrxa5HnPEluPBMBnYfubDl94cT7iJLzPrSA8Z94dGXSaQ
|
3567
3569
|
pYXFuXqUPoeovQA=
|
3568
3570
|
-----END CERTIFICATE-----
|
3571
|
+
|
3572
|
+
TWCA CYBER Root CA
|
3573
|
+
==================
|
3574
|
+
-----BEGIN CERTIFICATE-----
|
3575
|
+
MIIFjTCCA3WgAwIBAgIQQAE0jMIAAAAAAAAAATzyxjANBgkqhkiG9w0BAQwFADBQMQswCQYDVQQG
|
3576
|
+
EwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJUV0NB
|
3577
|
+
IENZQkVSIFJvb3QgQ0EwHhcNMjIxMTIyMDY1NDI5WhcNNDcxMTIyMTU1OTU5WjBQMQswCQYDVQQG
|
3578
|
+
EwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDEx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bNcAu3p4ULs3a2D6f/CIsLJc+o1IN1KriWiLb73y0ttGlTITVX1olN
|
3592
|
+
c79pj3CjYcya2x6a4CD4bLubIp1dhDGaLIrdaqHXKGnK/nZVekZn68xDiBaiA9a5F/gZbG0jAn/x
|
3593
|
+
X9AKKSM70aoK7akXJlQKTcKlTfjF/biBzysseKNnTKkHmvPfXvt89YnNdJdhEGoHK4Fa0o635yDR
|
3594
|
+
IG4kqIQnoVesqlVYL9zZyvpoBJ7tRCT5dEA7IzOrg1oYJkK2bVS1FmAwbLGg+LhBoF1JSdJlBTrq
|
3595
|
+
/p1hvIbZv97Tujqxf36SNI7JAG7cmL3c7IAFrQI932XtCwP39xaEBDG6k5TY8hL4iuO/Qq+n1M0R
|
3596
|
+
FxbIQh0UqEL20kCGoE8jypZFVmAGzbdVAaYBlGX+bgUJurSkquLvWL69J1bY73NxW0Qz8ppy6rBe
|
3597
|
+
Pm6pUlvscG21h483XjyMnM7k8M4MZ0HMzvaAq07MTFb1wWFZk7Q+ptq4NxKfKjLji7gh7MMrZQzv
|
3598
|
+
It6IKTtM1/r+t+FHvpw+PoP7UV31aPcuIYXcv/Fa4nzXxeSDwWrruoBa3lwtcHb4yOWHh8qgnaHl
|
3599
|
+
IhInD0Q9HWzq1MKLL295q39QpsQZp6F6t5b5wR9iWqJDB0BeJsas7a5wFsWqynKKTbDPAYsDP27X
|
3600
|
+
-----END CERTIFICATE-----
|
3601
|
+
|
3602
|
+
SecureSign Root CA12
|
3603
|
+
====================
|
3604
|
+
-----BEGIN CERTIFICATE-----
|
3605
|
+
MIIDcjCCAlqgAwIBAgIUZvnHwa/swlG07VOX5uaCwysckBYwDQYJKoZIhvcNAQELBQAwUTELMAkG
|
3606
|
+
A1UEBhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRT
|
3607
|
+
ZWN1cmVTaWduIFJvb3QgQ0ExMjAeFw0yMDA0MDgwNTM2NDZaFw00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PiZwud9AzqVN/Ssq+xIvEg37xEHA==
|
3621
|
+
-----END CERTIFICATE-----
|
3622
|
+
|
3623
|
+
SecureSign Root CA14
|
3624
|
+
====================
|
3625
|
+
-----BEGIN CERTIFICATE-----
|
3626
|
+
MIIFcjCCA1qgAwIBAgIUZNtaDCBO6Ncpd8hQJ6JaJ90t8sswDQYJKoZIhvcNAQEMBQAwUTELMAkG
|
3627
|
+
A1UEBhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRT
|
3628
|
+
ZWN1cmVTaWduIFJvb3QgQ0ExNDAeFw0yMDA0MDgwNzA2MTlaFw00NTA0MDgwNzA2MTlaMFExCzAJ
|
3629
|
+
BgNVBAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMU
|
3630
|
+
U2VjdXJlU2lnbiBSb290IENBMTQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDF0nqh
|
3631
|
+
1oq/FjHQmNE6lPxauG4iwWL3pwon71D2LrGeaBLwbCRjOfHw3xDG3rdSINVSW0KZnvOgvlIfX8xn
|
3632
|
+
bacuUKLBl422+JX1sLrcneC+y9/3OPJH9aaakpUqYllQC6KxNedlsmGy6pJxaeQp8E+BgQQ8sqVb
|
3633
|
+
1MWoWWd7VRxJq3qdwudzTe/NCcLEVxLbAQ4jeQkHO6Lo/IrPj8BGJJw4J+CDnRugv3gVEOuGTgpa
|
3634
|
+
/d/aLIJ+7sr2KeH6caH3iGicnPCNvg9JkdjqOvn90Ghx2+m1K06Ckm9mH+Dw3EzsytHqunQG+bOE
|
3635
|
+
kJTRX45zGRBdAuVwpcAQ0BB8b8VYSbSwbprafZX1zNoCr7gsfXmPvkPx+SgojQlD+Ajda8iLLCSx
|
3636
|
+
jVIHvXiby8posqTdDEx5YMaZ0ZPxMBoH064iwurO8YQJzOAUbn8/ftKChazcqRZOhaB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HXumZNTfxPWQrqaA0k89jL9WB365jJ6UeTo3cKXhZ+PmhIIynJkBugnLN
|
3650
|
+
eLLIjzwec+fBH7/PzqUqm9tEZDKgu39cJRNItX+S
|
3651
|
+
-----END CERTIFICATE-----
|
3652
|
+
|
3653
|
+
SecureSign Root CA15
|
3654
|
+
====================
|
3655
|
+
-----BEGIN CERTIFICATE-----
|
3656
|
+
MIICIzCCAamgAwIBAgIUFhXHw9hJp75pDIqI7fBw+d23PocwCgYIKoZIzj0EAwMwUTELMAkGA1UE
|
3657
|
+
BhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRTZWN1
|
3658
|
+
cmVTaWduIFJvb3QgQ0ExNTAeFw0yMDA0MDgwODMyNTZaFw00NTA0MDgwODMyNTZaMFExCzAJBgNV
|
3659
|
+
BAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMUU2Vj
|
3660
|
+
dXJlU2lnbiBSb290IENBMTUwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQLUHSNZDKZmbPSYAi4Io5G
|
3661
|
+
dCx4wCtELW1fHcmuS1Iggz24FG1Th2CeX2yF2wYUleDHKP+dX+Sq8bOLbe1PL0vJSpSRZHX+AezB
|
3662
|
+
2Ot6lHhWGENfa4HL9rzatAy2KZMIaY+jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD
|
3663
|
+
AgEGMB0GA1UdDgQWBBTrQciu/NWeUUj1vYv0hyCTQSvT9DAKBggqhkjOPQQDAwNoADBlAjEA2S6J
|
3664
|
+
fl5OpBEHvVnCB96rMjhTKkZEBhd6zlHp4P9mLQlO4E/0BdGF9jVg3PVys0Z9AjBEmEYagoUeYWmJ
|
3665
|
+
SwdLZrWeqrqgHkHZAXQ6bkU6iYAZezKYVWOr62Nuk22rGwlgMU4=
|
3666
|
+
-----END CERTIFICATE-----
|
data/lib/excon/connection.rb
CHANGED
@@ -446,6 +446,12 @@ module Excon
|
|
446
446
|
raise ArgumentError.new("Invalid validation type '#{validation}'")
|
447
447
|
end
|
448
448
|
|
449
|
+
if validation == :connection && params[:omit_default_port] != true
|
450
|
+
Excon.display_warning(
|
451
|
+
'The `omit_default_port` connection option is deprecated, please use `include_default_port` instead.'
|
452
|
+
)
|
453
|
+
end
|
454
|
+
|
449
455
|
invalid_keys = params.keys - valid_keys
|
450
456
|
unless invalid_keys.empty?
|
451
457
|
Excon.display_warning("Invalid Excon #{validation} keys: #{invalid_keys.map(&:inspect).join(', ')}")
|
data/lib/excon/constants.rb
CHANGED
@@ -14,9 +14,11 @@ module Excon
|
|
14
14
|
DEFAULT_RETRY_LIMIT = 4
|
15
15
|
|
16
16
|
DEFAULT_RETRY_ERRORS = [
|
17
|
-
Excon::Error::
|
17
|
+
Excon::Error::RequestTimeout,
|
18
|
+
Excon::Error::Server,
|
18
19
|
Excon::Error::Socket,
|
19
|
-
Excon::Error::
|
20
|
+
Excon::Error::Timeout,
|
21
|
+
Excon::Error::TooManyRequests
|
20
22
|
].freeze
|
21
23
|
|
22
24
|
FORCE_ENC = CR_NL.respond_to?(:force_encoding)
|
@@ -84,6 +86,7 @@ module Excon
|
|
84
86
|
keepalive
|
85
87
|
host
|
86
88
|
hostname
|
89
|
+
include_default_port
|
87
90
|
omit_default_port
|
88
91
|
nonblock
|
89
92
|
reuseaddr
|
@@ -151,14 +154,16 @@ module Excon
|
|
151
154
|
instrumentor_name: 'excon',
|
152
155
|
middlewares: [
|
153
156
|
Excon::Middleware::ResponseParser,
|
157
|
+
Excon::Middleware::Decompress,
|
154
158
|
Excon::Middleware::Expects,
|
155
159
|
Excon::Middleware::Idempotent,
|
156
160
|
Excon::Middleware::Instrumentor,
|
157
161
|
Excon::Middleware::Mock
|
158
162
|
],
|
159
163
|
mock: false,
|
164
|
+
include_default_port: false,
|
160
165
|
nonblock: true,
|
161
|
-
omit_default_port:
|
166
|
+
omit_default_port: true,
|
162
167
|
persistent: false,
|
163
168
|
read_timeout: 60,
|
164
169
|
resolv_resolver: nil,
|
@@ -1,41 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Excon
|
3
4
|
module Middleware
|
4
5
|
class Decompress < Excon::Middleware::Base
|
5
|
-
|
6
6
|
INFLATE_ZLIB_OR_GZIP = 47 # Zlib::MAX_WBITS + 32
|
7
7
|
INFLATE_RAW = -15 # Zlib::MAX_WBITS * -1
|
8
8
|
|
9
9
|
def request_call(datum)
|
10
|
-
unless datum.
|
11
|
-
key = datum[:headers].keys.detect {|k| k.to_s.casecmp('Accept-Encoding')
|
12
|
-
if datum[:headers][key].to_s.empty?
|
13
|
-
datum[:headers][key] = 'deflate, gzip'
|
14
|
-
end
|
10
|
+
unless datum.key?(:response_block)
|
11
|
+
key = datum[:headers].keys.detect { |k| k.to_s.casecmp('Accept-Encoding').zero? } || 'Accept-Encoding'
|
12
|
+
datum[:headers][key] = 'deflate, gzip' if datum[:headers][key].to_s.empty?
|
15
13
|
end
|
16
14
|
@stack.request_call(datum)
|
17
15
|
end
|
18
16
|
|
19
17
|
def response_call(datum)
|
20
18
|
body = datum[:response][:body]
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Zlib::Inflate.new(INFLATE_RAW).inflate(body)
|
30
|
-
end
|
31
|
-
encodings.pop
|
32
|
-
elsif encoding.casecmp('gzip') == 0 || encoding.casecmp('x-gzip') == 0
|
33
|
-
datum[:response][:body] = Zlib::GzipReader.new(StringIO.new(body)).read
|
34
|
-
encodings.pop
|
35
|
-
end
|
36
|
-
datum[:response][:headers][key] = encodings.join(', ')
|
19
|
+
if !(datum.key?(:response_block) || body.nil? || body.empty?) &&
|
20
|
+
(key = datum[:response][:headers].keys.detect { |k| k.casecmp('Content-Encoding').zero? })
|
21
|
+
encodings = Utils.split_header_value(datum[:response][:headers][key])
|
22
|
+
if encodings.last.casecmp('deflate').zero?
|
23
|
+
datum[:response][:body] = begin
|
24
|
+
Zlib::Inflate.new(INFLATE_ZLIB_OR_GZIP).inflate(body)
|
25
|
+
rescue Zlib::DataError # fallback to raw on error
|
26
|
+
Zlib::Inflate.new(INFLATE_RAW).inflate(body)
|
37
27
|
end
|
28
|
+
encodings.pop
|
29
|
+
elsif encodings.last.casecmp('gzip').zero? || encodings.last.casecmp('x-gzip').zero?
|
30
|
+
datum[:response][:body] = Zlib::GzipReader.new(StringIO.new(body)).read
|
31
|
+
encodings.pop
|
38
32
|
end
|
33
|
+
datum[:response][:headers][key] = encodings.join(', ')
|
39
34
|
end
|
40
35
|
@stack.response_call(datum)
|
41
36
|
end
|
data/lib/excon/ssl_socket.rb
CHANGED
@@ -108,7 +108,7 @@ module Excon
|
|
108
108
|
end
|
109
109
|
|
110
110
|
if @data[:proxy]
|
111
|
-
request = "CONNECT #{@data[:host]}#{
|
111
|
+
request = "CONNECT #{@data[:host]}#{Excon::HTTP_1_1}" \
|
112
112
|
"Host: #{@data[:host]}#{port_string(@data)}#{Excon::CR_NL}"
|
113
113
|
|
114
114
|
if @data[:proxy].has_key?(:user) || @data[:proxy].has_key?(:password)
|
data/lib/excon/utils.rb
CHANGED
@@ -62,11 +62,33 @@ module Excon
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def port_string(datum)
|
65
|
-
if
|
66
|
-
|
65
|
+
if !default_port?(datum) || datum[:include_default_port] || !datum[:omit_default_port]
|
66
|
+
":#{datum[:port]}"
|
67
67
|
else
|
68
|
-
'
|
68
|
+
''
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Used to normalize queries for stubs, based on Rack::Utils.parse_query
|
73
|
+
def parse_query_string(string)
|
74
|
+
params = {}
|
75
|
+
|
76
|
+
string.split(/[&;] */n).each do |pair|
|
77
|
+
key, value = pair.split('=', 2).map { |x| CGI.unescape(x) }
|
78
|
+
|
79
|
+
params[key] = if params[key]
|
80
|
+
[params[key], value].flatten
|
81
|
+
else
|
82
|
+
value
|
83
|
+
end
|
69
84
|
end
|
85
|
+
|
86
|
+
params
|
87
|
+
end
|
88
|
+
|
89
|
+
def default_port?(datum)
|
90
|
+
(datum[:scheme].casecmp('http').zero? && datum[:port] == 80) ||
|
91
|
+
(datum[:scheme].casecmp('https').zero? && datum[:port] == 443)
|
70
92
|
end
|
71
93
|
|
72
94
|
def query_string(datum)
|
data/lib/excon/version.rb
CHANGED
data/lib/excon.rb
CHANGED
@@ -19,6 +19,7 @@ require 'excon/version'
|
|
19
19
|
require 'excon/extensions/uri'
|
20
20
|
|
21
21
|
require 'excon/middlewares/base'
|
22
|
+
require 'excon/middlewares/decompress'
|
22
23
|
require 'excon/middlewares/expects'
|
23
24
|
require 'excon/middlewares/idempotent'
|
24
25
|
require 'excon/middlewares/instrumentor'
|
@@ -32,7 +33,6 @@ require 'excon/utils'
|
|
32
33
|
require 'excon/connection'
|
33
34
|
require 'excon/headers'
|
34
35
|
require 'excon/response'
|
35
|
-
require 'excon/middlewares/decompress'
|
36
36
|
require 'excon/middlewares/escape_path'
|
37
37
|
require 'excon/middlewares/redirect_follower'
|
38
38
|
require 'excon/middlewares/capture_cookies'
|
@@ -143,7 +143,7 @@ module Excon
|
|
143
143
|
uri = URI.parse(url)
|
144
144
|
request_params = {
|
145
145
|
host: uri.host,
|
146
|
-
path: uri.path,
|
146
|
+
path: uri.path.empty? ? '/' : uri.path,
|
147
147
|
port: uri.port,
|
148
148
|
query: uri.query,
|
149
149
|
scheme: uri.scheme
|
@@ -162,6 +162,9 @@ module Excon
|
|
162
162
|
end
|
163
163
|
request_params[:headers] = headers
|
164
164
|
end
|
165
|
+
if request_params.key?(:query) && request_params[:query].instance_of?(String)
|
166
|
+
request_params[:query] = Utils.parse_query_string(request_params[:query])
|
167
|
+
end
|
165
168
|
if block_given?
|
166
169
|
raise(ArgumentError, 'stub requires either response_params OR a block') if response_params
|
167
170
|
|
@@ -182,6 +185,9 @@ module Excon
|
|
182
185
|
if (method = request_params.delete(:method))
|
183
186
|
request_params[:method] = method.to_s.downcase.to_sym
|
184
187
|
end
|
188
|
+
if request_params.key?(:query) && request_params[:query].instance_of?(String)
|
189
|
+
request_params[:query] = Utils.parse_query_string(request_params[:query])
|
190
|
+
end
|
185
191
|
Excon.stubs.each do |stub, response_params|
|
186
192
|
captures = { headers: {} }
|
187
193
|
headers_match = !stub.key?(:headers) || stub[:headers].keys.all? do |key|
|
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.
|
4
|
+
version: 1.0.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-
|
13
|
+
date: 2024-10-24 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.
|
254
|
+
rubygems_version: 3.5.18
|
255
255
|
signing_key:
|
256
256
|
specification_version: 4
|
257
257
|
summary: speed, persistence, http(s)
|