excon 0.62.0 → 0.63.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of excon might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.github/stale.yml +17 -0
- data/.travis.yml +7 -19
- data/LICENSE.md +1 -1
- data/README.md +5 -4
- data/changelog.txt +25 -0
- data/data/cacert.pem +440 -994
- data/excon.gemspec +9 -0
- data/lib/excon.rb +9 -1
- data/lib/excon/connection.rb +52 -35
- data/lib/excon/constants.rb +33 -13
- data/lib/excon/error.rb +3 -0
- data/lib/excon/instrumentors/logging_instrumentor.rb +3 -14
- data/lib/excon/instrumentors/standard_instrumentor.rb +1 -8
- data/lib/excon/middlewares/base.rb +6 -0
- data/lib/excon/middlewares/expects.rb +6 -0
- data/lib/excon/middlewares/idempotent.rb +20 -3
- data/lib/excon/middlewares/instrumentor.rb +8 -0
- data/lib/excon/middlewares/mock.rb +8 -0
- data/lib/excon/middlewares/response_parser.rb +3 -0
- data/lib/excon/pretty_printer.rb +1 -8
- data/lib/excon/socket.rb +36 -10
- data/lib/excon/ssl_socket.rb +7 -0
- data/lib/excon/utils.rb +23 -4
- data/lib/excon/version.rb +1 -1
- data/spec/excon/test/server_spec.rb +2 -2
- data/spec/helpers/warning_helpers.rb +9 -0
- data/spec/requests/unix_socket_spec.rb +2 -10
- data/spec/requests/validation_spec.rb +80 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/shared_contexts/test_stub_context.rb +11 -0
- data/spec/support/shared_examples/shared_example_for_clients.rb +6 -4
- data/tests/authorization_header_tests.rb +19 -21
- data/tests/bad_tests.rb +22 -0
- data/tests/batch_requests.rb +1 -1
- data/tests/complete_responses.rb +1 -1
- data/tests/data/127.0.0.1.cert.crt +15 -18
- data/tests/data/127.0.0.1.cert.key +28 -27
- data/tests/data/excon.cert.crt +15 -18
- data/tests/data/excon.cert.key +28 -27
- data/tests/error_tests.rb +1 -1
- data/tests/instrumentors/logging_instrumentor_tests.rb +28 -0
- data/tests/middlewares/decompress_tests.rb +1 -1
- data/tests/middlewares/idempotent_tests.rb +56 -17
- data/tests/middlewares/mock_tests.rb +2 -2
- data/tests/pipeline_tests.rb +1 -1
- data/tests/request_tests.rb +5 -6
- data/tests/response_tests.rb +1 -1
- data/tests/servers/bad.rb +5 -0
- data/tests/servers/good.rb +0 -8
- data/tests/servers/good_ipv4.rb +8 -0
- data/tests/servers/good_ipv6.rb +8 -0
- data/tests/test_helper.rb +27 -36
- metadata +17 -5
data/tests/bad_tests.rb
CHANGED
@@ -2,6 +2,28 @@ Shindo.tests('Excon bad server interaction') do
|
|
2
2
|
|
3
3
|
with_server('bad') do
|
4
4
|
|
5
|
+
tests('header splitting') do
|
6
|
+
|
7
|
+
tests('prevents key splitting').raises(Excon::Errors::InvalidHeaderKey) do
|
8
|
+
connection = Excon.new('http://127.0.0.1:9292')
|
9
|
+
connection.request(
|
10
|
+
headers: { "Foo\r\nBar" => "baz" },
|
11
|
+
method: :get,
|
12
|
+
path: '/echo'
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
tests('prevents value splitting').raises(Excon::Errors::InvalidHeaderValue) do
|
17
|
+
connection = Excon.new('http://127.0.0.1:9292')
|
18
|
+
connection.request(
|
19
|
+
headers: { Foo: "bar\r\nBaz: qux" },
|
20
|
+
method: :get,
|
21
|
+
path: '/echo'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
5
27
|
tests('bad server: causes EOFError') do
|
6
28
|
|
7
29
|
tests('with no content length and no chunking') do
|
data/tests/batch_requests.rb
CHANGED
data/tests/complete_responses.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
eaZl32yLu/7SmNEpyYNUWurkyB7tk77+7Ai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zLorbCTpkCgYAZcGUbVGUBHYtNEf1vhY75
|
25
|
+
7qeuDbxlwxEX8D6HEJ0L6GpFgp6e/2IhzfgGJCW7gcbQHDwBixPva/ybvAsR64jG
|
26
|
+
c5n/TNguSv+JjpLZVl7MKmh4JssnEefBXT/LiSsz7LHeRm+SxxQptmsTYR5ODA8w
|
27
|
+
E1w/yHz1wrIocfCyb1J5+w==
|
28
|
+
-----END PRIVATE KEY-----
|
data/tests/data/excon.cert.crt
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
0r6Lvook0ur+WXalGLu8110bCa4k+00SlZg0qZISlfrZyF5ofybylMjyy/qArgUy
|
18
|
-
8eltHfWbPhJEqf1yDPz2xCYGGCSplJMpvAhvSf4GSM55B27AoPlYlaS5wEaJf8Ft
|
19
|
-
g72ESuzICOQ617jOTeasIkkkoINIdnW1oA==
|
2
|
+
MIICvDCCAaQCCQCS1Yn8FMcKlzANBgkqhkiG9w0BAQsFADAgMQ4wDAYDVQQDDAVl
|
3
|
+
eGNvbjEOMAwGA1UECgwFZXhjb24wHhcNMTkwNDEyMTQzMTU2WhcNMjAwNDExMTQz
|
4
|
+
MTU2WjAgMQ4wDAYDVQQDDAVleGNvbjEOMAwGA1UECgwFZXhjb24wggEiMA0GCSqG
|
5
|
+
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCycrlh3FfPSv8kDJrvnRJwdFPUp+23juTD
|
6
|
+
Pb8A7YBM1rw/z5WKJGhmdYAnhyhSO5KWuKH4dUTykNn0uFz0J5bXKclU6kjatM58
|
7
|
+
IF96tc7kugDXCy+IBnmf2pM2fDrmji0c50abcHu70HQvxC+BQS9Id0iZ2G12q539
|
8
|
+
lgxvSAquyh9NBhHhxW7aNUvPuueUVlfIKshd50aHtxWlMxr9hvOZzldj9C38du0Y
|
9
|
+
uY+klTReMY2UCK2cm9S31QSP4gSeepGeaw6buV5pGNhiK9UR6dVVF4qFu21ZE0aN
|
10
|
+
pNlCaBK8zCT5toxkgca096cKFOY6nfrhzhDdd2ULlRc/zpAkYuVRAgMBAAEwDQYJ
|
11
|
+
KoZIhvcNAQELBQADggEBAIaZW9JnfhFhnq6bu0qo0HFrfEnpOhiMHIp2nyAoXdQI
|
12
|
+
k/3Dxfd17LmfonQDkwo0D+tp3yu7xL2+qVIPElyWmKnhF13U4lhiGhAbMopV1dSH
|
13
|
+
oUU5uk3DHfeWcTurC9PMX5MnozIaogmffkTEhXBOdaNI6vfk2Gs0tqYMGyIV2VNp
|
14
|
+
KMegKCP2gX+PbqzXq6DzVCxbeDGdjKxpFQqas1W+soL/I9Hg7w/S8W9SpNP0tsfd
|
15
|
+
JB7Xl2urXNK8HnsRt9uhwP6ZSIdtVqr62CqM2z0SvuTTdPTDn2TMGd0nHacpmqN0
|
16
|
+
vUHeoZheUD+w8SikrQnr4/Ft3JrH0SKY0FlgVIGcaPg=
|
20
17
|
-----END CERTIFICATE-----
|
data/tests/data/excon.cert.key
CHANGED
@@ -1,27 +1,28 @@
|
|
1
|
-
-----BEGIN
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
-----BEGIN PRIVATE KEY-----
|
2
|
+
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCycrlh3FfPSv8k
|
3
|
+
DJrvnRJwdFPUp+23juTDPb8A7YBM1rw/z5WKJGhmdYAnhyh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fPAUKIVC4BLd0O9U6z9iudKKyfEKwvWC
|
19
|
+
G64SHm6RCwKBgDDifaOQvjC3VkXlCWsP54iCCh3L5e25FxA5Dhm2GZF3Fv9/ZUdS
|
20
|
+
B3VefuyJ6MVI7bYUPUhsE+i6NyZ+fwpoOMDh7OHNGG4v/Lc+M/j7NpnUNmQraii2
|
21
|
+
tUhhPmYo1O8Og+GCemlcuaOXVZssCbUeLi2YN1HKtmXoZ7pdcgqMWMshAoGAFZCZ
|
22
|
+
dsuudIVnoHQzJlxzBhyS+sH4dPSWXY9JDhn3z1cbFZ2FQqOQnBzx4KCAtwDzo/Bi
|
23
|
+
Ow3OnDrBPiue0cMDsKvzi5EgUZoUMchDoxN4nnCcY74H+wmGERck9sgQKKIsC10h
|
24
|
+
+eRMD6VlLqPP82m7kTwNySKpGuUeR88X0XZnGgsCgYB26Hpm7rUJY/sUCyEQxqW+
|
25
|
+
Opt8vOBV0ipapFD7O7VKImz7wALKBs6oiQGr+AoN/YavIYbubnmzP8jSUoqeWzFR
|
26
|
+
c4s3/sozur+1sbFqk/lJeSdvogY2CT4qgQx9OrZBynSWYldHig9HEeU5a56oh9vv
|
27
|
+
Vns6XV2XQMGmvjg9yetRig==
|
28
|
+
-----END PRIVATE KEY-----
|
data/tests/error_tests.rb
CHANGED
@@ -35,7 +35,7 @@ Shindo.tests('HTTPStatusError request/response debugging') do
|
|
35
35
|
Excon.new('http://localhost', path: "foo\r\nbar: baz")
|
36
36
|
false
|
37
37
|
rescue => err
|
38
|
-
err.to_s.include? "foo\r\nbar: baz"
|
38
|
+
err.to_s.include?(RUBY_VERSION >= '2.6.0' ? 'foo\r\nbar: baz' : "foo\r\nbar: baz")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
Shindo.tests('logging instrumentor') do
|
4
|
+
env_init
|
5
|
+
|
6
|
+
tests("connection logger").returns(true) do
|
7
|
+
Excon.stub({:method => :get}, {body: 'body', status: 200})
|
8
|
+
|
9
|
+
log_path = "/tmp/excon_#{Time.now.to_i}.txt"
|
10
|
+
logger = Logger.new(log_path)
|
11
|
+
# omit datetime to simplify test matcher
|
12
|
+
logger.formatter = proc do |severity, datetime, progname, msg|
|
13
|
+
"#{msg}\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
connection = Excon.new(
|
17
|
+
'http://127.0.0.1:9292',
|
18
|
+
instrumentor: Excon::LoggingInstrumentor,
|
19
|
+
logger: logger,
|
20
|
+
mock: true
|
21
|
+
)
|
22
|
+
response = connection.request(method: :get, path: '/logger')
|
23
|
+
File.readlines(log_path)[1..2] == [
|
24
|
+
"request: http://127.0.0.1/logger\n",
|
25
|
+
"response: body\n"
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
@@ -9,12 +9,12 @@ Shindo.tests('Excon request idempotencey') do
|
|
9
9
|
Excon.stubs.clear
|
10
10
|
end
|
11
11
|
|
12
|
-
tests("Non-idempotent call with an erroring socket").raises(Excon::
|
12
|
+
tests("Non-idempotent call with an erroring socket").raises(Excon::Error::Socket) do
|
13
13
|
run_count = 0
|
14
14
|
Excon.stub({:method => :get}) { |params|
|
15
15
|
run_count += 1
|
16
16
|
if run_count <= 3 # First 3 calls fail.
|
17
|
-
raise Excon::
|
17
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
18
18
|
else
|
19
19
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
20
20
|
end
|
@@ -28,7 +28,7 @@ Shindo.tests('Excon request idempotencey') do
|
|
28
28
|
Excon.stub({:method => :get}) { |params|
|
29
29
|
run_count += 1
|
30
30
|
if run_count <= 3 # First 3 calls fail.
|
31
|
-
raise Excon::
|
31
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
32
32
|
else
|
33
33
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
34
34
|
end
|
@@ -38,12 +38,12 @@ Shindo.tests('Excon request idempotencey') do
|
|
38
38
|
response.status
|
39
39
|
end
|
40
40
|
|
41
|
-
tests("Idempotent request with socket erroring first 5 times").raises(Excon::
|
41
|
+
tests("Idempotent request with socket erroring first 5 times").raises(Excon::Error::Socket) do
|
42
42
|
run_count = 0
|
43
43
|
Excon.stub({:method => :get}) { |params|
|
44
44
|
run_count += 1
|
45
45
|
if run_count <= 5 # First 5 calls fail.
|
46
|
-
raise Excon::
|
46
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
47
47
|
else
|
48
48
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
49
49
|
end
|
@@ -58,7 +58,7 @@ Shindo.tests('Excon request idempotencey') do
|
|
58
58
|
Excon.stub({:method => :get}) { |params|
|
59
59
|
run_count += 1
|
60
60
|
if run_count <= 1 # First call fails.
|
61
|
-
raise Excon::
|
61
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
62
62
|
else
|
63
63
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
64
64
|
end
|
@@ -68,12 +68,12 @@ Shindo.tests('Excon request idempotencey') do
|
|
68
68
|
response.status
|
69
69
|
end
|
70
70
|
|
71
|
-
tests("Lowered retry limit with socket erroring first 3 times").raises(Excon::
|
71
|
+
tests("Lowered retry limit with socket erroring first 3 times").raises(Excon::Error::Socket) do
|
72
72
|
run_count = 0
|
73
73
|
Excon.stub({:method => :get}) { |params|
|
74
74
|
run_count += 1
|
75
75
|
if run_count <= 3 # First 3 calls fail.
|
76
|
-
raise Excon::
|
76
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
77
77
|
else
|
78
78
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
79
79
|
end
|
@@ -88,7 +88,7 @@ Shindo.tests('Excon request idempotencey') do
|
|
88
88
|
Excon.stub({:method => :get}) { |params|
|
89
89
|
run_count += 1
|
90
90
|
if run_count <= 5 # First 5 calls fail.
|
91
|
-
raise Excon::
|
91
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
92
92
|
else
|
93
93
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
94
94
|
end
|
@@ -98,12 +98,12 @@ Shindo.tests('Excon request idempotencey') do
|
|
98
98
|
response.status
|
99
99
|
end
|
100
100
|
|
101
|
-
tests("Raised retry limit with socket erroring first 9 times").raises(Excon::
|
101
|
+
tests("Raised retry limit with socket erroring first 9 times").raises(Excon::Error::Socket) do
|
102
102
|
run_count = 0
|
103
103
|
Excon.stub({:method => :get}) { |params|
|
104
104
|
run_count += 1
|
105
105
|
if run_count <= 9 # First 9 calls fail.
|
106
|
-
raise Excon::
|
106
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
107
107
|
else
|
108
108
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
109
109
|
end
|
@@ -118,7 +118,7 @@ Shindo.tests('Excon request idempotencey') do
|
|
118
118
|
Excon.stub({:method => :get}) { |params|
|
119
119
|
run_count += 1
|
120
120
|
if run_count <= 5 # First 5 calls fail.
|
121
|
-
raise Excon::
|
121
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
122
122
|
else
|
123
123
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
124
124
|
end
|
@@ -133,7 +133,7 @@ Shindo.tests('Excon request idempotencey') do
|
|
133
133
|
Excon.stub({:method => :get}) { |params|
|
134
134
|
run_count += 1
|
135
135
|
if run_count <= 2 # First 5 calls fail.
|
136
|
-
raise Excon::
|
136
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
137
137
|
else
|
138
138
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
139
139
|
end
|
@@ -145,12 +145,12 @@ Shindo.tests('Excon request idempotencey') do
|
|
145
145
|
response.status
|
146
146
|
end
|
147
147
|
|
148
|
-
tests("Retry limit and sleep in constructor with socket erroring first 2 times").raises(Excon::
|
148
|
+
tests("Retry limit and sleep in constructor with socket erroring first 2 times").raises(Excon::Error::Socket) do
|
149
149
|
run_count = 0
|
150
150
|
Excon.stub({:method => :get}) { |params|
|
151
151
|
run_count += 1
|
152
152
|
if run_count <= 2 # First 5 calls fail.
|
153
|
-
raise Excon::
|
153
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
154
154
|
else
|
155
155
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
156
156
|
end
|
@@ -161,6 +161,45 @@ Shindo.tests('Excon request idempotencey') do
|
|
161
161
|
response.status
|
162
162
|
end
|
163
163
|
|
164
|
+
tests("Idempotent request with custom error first 3 times").returns(200) do
|
165
|
+
run_count = 0
|
166
|
+
Excon.stub({:method => :get}) { |params|
|
167
|
+
run_count += 1
|
168
|
+
if run_count <= 3 # First 3 calls fail.
|
169
|
+
raise "oops"
|
170
|
+
else
|
171
|
+
{:body => params[:body], :headers => params[:headers], :status => 200}
|
172
|
+
end
|
173
|
+
}
|
174
|
+
|
175
|
+
response = @connection.request(:method => :get, :idempotent => true, :retry_errors => [RuntimeError], :path => '/some-path')
|
176
|
+
response.status
|
177
|
+
end
|
178
|
+
|
179
|
+
tests("Idempotent request with custom error first 5 times").raises(RuntimeError) do
|
180
|
+
run_count = 0
|
181
|
+
Excon.stub({:method => :get}) { |params|
|
182
|
+
run_count += 1
|
183
|
+
if run_count <= 5 # First 5 calls fail.
|
184
|
+
raise "oops"
|
185
|
+
else
|
186
|
+
{:body => params[:body], :headers => params[:headers], :status => 200}
|
187
|
+
end
|
188
|
+
}
|
189
|
+
|
190
|
+
response = @connection.request(:method => :get, :idempotent => true, :retry_errors => [RuntimeError], :path => '/some-path')
|
191
|
+
response.status
|
192
|
+
end
|
193
|
+
|
194
|
+
tests("Overriding default retry_errors").raises(Excon::Error::Socket) do
|
195
|
+
Excon.stub({:method => :get}) { |params|
|
196
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
197
|
+
}
|
198
|
+
|
199
|
+
response = @connection.request(:method => :get, :idempotent => true, :retry_errors => [RuntimeError], :path => '/some-path')
|
200
|
+
response.status
|
201
|
+
end
|
202
|
+
|
164
203
|
class Block
|
165
204
|
attr_reader :rewound
|
166
205
|
def initialize
|
@@ -178,7 +217,7 @@ Shindo.tests('Excon request idempotencey') do
|
|
178
217
|
Excon.stub({:method => :get}) { |params|
|
179
218
|
run_count += 1
|
180
219
|
if run_count <= 1 # First call fails.
|
181
|
-
raise Excon::
|
220
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
182
221
|
else
|
183
222
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
184
223
|
end
|
@@ -193,7 +232,7 @@ Shindo.tests('Excon request idempotencey') do
|
|
193
232
|
Excon.stub({:method => :get}) { |params|
|
194
233
|
run_count += 1
|
195
234
|
if run_count <= 1 # First call fails.
|
196
|
-
raise Excon::
|
235
|
+
raise Excon::Error::Socket.new(Exception.new "Mock Error")
|
197
236
|
else
|
198
237
|
{:body => params[:body], :headers => params[:headers], :status => 200}
|
199
238
|
end
|