async-io 1.29.0 → 1.30.0
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/lib/async/io/host_endpoint.rb +1 -1
- data/lib/async/io/trap.rb +4 -3
- data/lib/async/io/version.rb +1 -1
- metadata +39 -91
- data/.editorconfig +0 -6
- data/.github/workflows/development.yml +0 -55
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.yardopts +0 -2
- data/Gemfile +0 -13
- data/README.md +0 -171
- data/async-io.gemspec +0 -30
- data/examples/allocations/byteslice.rb +0 -29
- data/examples/allocations/memory.rb +0 -16
- data/examples/allocations/read_chunks.rb +0 -18
- data/examples/chat/client.rb +0 -58
- data/examples/chat/server.rb +0 -83
- data/examples/defer/worker.rb +0 -29
- data/examples/echo/client.rb +0 -23
- data/examples/echo/server.rb +0 -58
- data/examples/issues/broken_ssl.rb +0 -15
- data/examples/issues/pipes.rb +0 -34
- data/examples/millions/client.rb +0 -44
- data/examples/millions/server.rb +0 -41
- data/examples/udp/client.rb +0 -14
- data/examples/udp/server.rb +0 -16
- data/gems/nio4r-2.3.gemfile +0 -3
- data/spec/addrinfo.rb +0 -16
- data/spec/async/io/buffer_spec.rb +0 -48
- data/spec/async/io/c10k_spec.rb +0 -138
- data/spec/async/io/echo_spec.rb +0 -75
- data/spec/async/io/endpoint_spec.rb +0 -105
- data/spec/async/io/generic_examples.rb +0 -73
- data/spec/async/io/generic_spec.rb +0 -107
- data/spec/async/io/notification_spec.rb +0 -46
- data/spec/async/io/protocol/line_spec.rb +0 -81
- data/spec/async/io/shared_endpoint/server_spec.rb +0 -72
- data/spec/async/io/shared_endpoint_spec.rb +0 -65
- data/spec/async/io/socket/tcp_spec.rb +0 -101
- data/spec/async/io/socket/udp_spec.rb +0 -65
- data/spec/async/io/socket_spec.rb +0 -149
- data/spec/async/io/ssl_server_spec.rb +0 -133
- data/spec/async/io/ssl_socket_spec.rb +0 -96
- data/spec/async/io/standard_spec.rb +0 -47
- data/spec/async/io/stream_context.rb +0 -30
- data/spec/async/io/stream_spec.rb +0 -337
- data/spec/async/io/tcp_socket_spec.rb +0 -84
- data/spec/async/io/threads_spec.rb +0 -59
- data/spec/async/io/trap_spec.rb +0 -52
- data/spec/async/io/udp_socket_spec.rb +0 -56
- data/spec/async/io/unix_endpoint_spec.rb +0 -106
- data/spec/async/io/unix_socket_spec.rb +0 -66
- data/spec/async/io/wrap/http_rb_spec.rb +0 -47
- data/spec/async/io/wrap/tcp_spec.rb +0 -79
- data/spec/spec_helper.rb +0 -15
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'async/io/tcp_socket'
|
24
|
-
|
25
|
-
RSpec.describe Async::IO::Socket do
|
26
|
-
include_context Async::RSpec::Reactor
|
27
|
-
|
28
|
-
# Shared port for localhost network tests.
|
29
|
-
let(:server_address) {Async::IO::Address.tcp("127.0.0.1", 6788)}
|
30
|
-
let(:local_address) {Async::IO::Address.tcp("127.0.0.1", 0)}
|
31
|
-
let(:data) {"The quick brown fox jumped over the lazy dog."}
|
32
|
-
|
33
|
-
let!(:server_task) do
|
34
|
-
# Accept a single incoming connection and then finish.
|
35
|
-
reactor.async do |task|
|
36
|
-
Async::IO::Socket.bind(server_address) do |server|
|
37
|
-
server.listen(10)
|
38
|
-
|
39
|
-
server.accept do |peer, address|
|
40
|
-
data = peer.read(512)
|
41
|
-
peer.write(data)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'basic tcp server' do
|
48
|
-
it "should start server and send data" do
|
49
|
-
reactor.async do
|
50
|
-
Async::IO::Socket.connect(server_address) do |client|
|
51
|
-
client.write(data)
|
52
|
-
client.close_write
|
53
|
-
|
54
|
-
expect(client.read(512)).to be == data
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'non-blocking tcp connect' do
|
61
|
-
it "can specify local address" do
|
62
|
-
reactor.async do |task|
|
63
|
-
Async::IO::Socket.connect(server_address, local_address: local_address) do |client|
|
64
|
-
client.write(data)
|
65
|
-
client.close_write
|
66
|
-
|
67
|
-
expect(client.read(512)).to be == data
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should start server and send data" do
|
73
|
-
reactor.async do |task|
|
74
|
-
Async::IO::Socket.connect(server_address) do |client|
|
75
|
-
client.write(data)
|
76
|
-
client.close_write
|
77
|
-
|
78
|
-
expect(client.read(512)).to be == data
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it "can connect socket and read/write in a different task" do
|
84
|
-
reactor.async do |task|
|
85
|
-
socket = Async::IO::Socket.connect(server_address)
|
86
|
-
|
87
|
-
expect(socket).to_not be_nil
|
88
|
-
expect(socket).to be_kind_of Async::Wrapper
|
89
|
-
|
90
|
-
reactor.async do
|
91
|
-
socket.write(data)
|
92
|
-
socket.close_write
|
93
|
-
|
94
|
-
expect(socket.read(512)).to be == data
|
95
|
-
|
96
|
-
socket.close
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'async/io/udp_socket'
|
24
|
-
|
25
|
-
RSpec.describe Async::IO::Socket do
|
26
|
-
include_context Async::RSpec::Reactor
|
27
|
-
|
28
|
-
# Shared port for localhost network tests.
|
29
|
-
let(:server_address) {Async::IO::Address.udp("127.0.0.1", 6778)}
|
30
|
-
let(:data) {"The quick brown fox jumped over the lazy dog."}
|
31
|
-
|
32
|
-
let!(:server_task) do
|
33
|
-
reactor.async do
|
34
|
-
Async::IO::Socket.bind(server_address) do |server|
|
35
|
-
packet, address = server.recvfrom(512)
|
36
|
-
|
37
|
-
server.send(packet, 0, address)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe 'basic udp server' do
|
43
|
-
it "should echo data back to peer" do
|
44
|
-
reactor.async do
|
45
|
-
Async::IO::Socket.connect(server_address) do |client|
|
46
|
-
client.send(data)
|
47
|
-
response = client.recv(512)
|
48
|
-
|
49
|
-
expect(response).to be == data
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should use unconnected socket" do
|
55
|
-
reactor.async do
|
56
|
-
Async::IO::UDPSocket.wrap(server_address.afamily) do |client|
|
57
|
-
client.send(data, 0, server_address)
|
58
|
-
response, address = client.recvfrom(512)
|
59
|
-
|
60
|
-
expect(response).to be == data
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,149 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'async/io/socket'
|
24
|
-
require 'async/io/address'
|
25
|
-
|
26
|
-
require_relative 'generic_examples'
|
27
|
-
|
28
|
-
RSpec.describe Async::IO::BasicSocket do
|
29
|
-
it_should_behave_like Async::IO::Generic
|
30
|
-
end
|
31
|
-
|
32
|
-
RSpec.describe Async::IO::Socket do
|
33
|
-
include_context Async::RSpec::Reactor
|
34
|
-
|
35
|
-
it_should_behave_like Async::IO::Generic
|
36
|
-
|
37
|
-
describe '#connect' do
|
38
|
-
let(:address) {Async::IO::Address.tcp('127.0.0.1', 12345)}
|
39
|
-
|
40
|
-
it "should fail to connect if no listening server" do
|
41
|
-
expect do
|
42
|
-
Async::IO::Socket.connect(address)
|
43
|
-
end.to raise_exception(Errno::ECONNREFUSED)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should close the socket when interrupted by a timeout" do
|
47
|
-
wrapper = double()
|
48
|
-
expect(Async::IO::Socket).to receive(:build).and_return(wrapper)
|
49
|
-
expect(wrapper).to receive(:connect).and_raise Async::TimeoutError
|
50
|
-
expect(wrapper).to receive(:close)
|
51
|
-
expect do
|
52
|
-
Async::IO::Socket.connect(address)
|
53
|
-
end.to raise_exception(Async::TimeoutError)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#bind' do
|
58
|
-
it "should fail to bind to port < 1024" do
|
59
|
-
address = Async::IO::Address.tcp('127.0.0.1', 1)
|
60
|
-
|
61
|
-
expect do
|
62
|
-
Async::IO::Socket.bind(address)
|
63
|
-
end.to raise_exception(Errno::EACCES)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "can bind to port 0" do
|
67
|
-
address = Async::IO::Address.tcp('127.0.0.1', 0)
|
68
|
-
|
69
|
-
Async::IO::Socket.bind(address) do |socket|
|
70
|
-
expect(socket.local_address.ip_port).to be > 10000
|
71
|
-
|
72
|
-
expect(Async::Task.current.annotation).to include("#{socket.local_address.ip_port}")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#sync' do
|
78
|
-
it "should set TCP_NODELAY" do
|
79
|
-
address = Async::IO::Address.tcp('127.0.0.1', 0)
|
80
|
-
|
81
|
-
socket = Async::IO::Socket.wrap(::Socket::AF_INET, ::Socket::SOCK_STREAM, ::Socket::IPPROTO_TCP)
|
82
|
-
|
83
|
-
socket.sync = true
|
84
|
-
expect(socket.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY).bool).to be true
|
85
|
-
|
86
|
-
socket.close
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe '#timeout' do
|
91
|
-
subject{described_class.pair(:UNIX, :STREAM, 0)}
|
92
|
-
|
93
|
-
it "should timeout while waiting to receive data" do
|
94
|
-
s1, s2 = *subject
|
95
|
-
|
96
|
-
s2.timeout = 1
|
97
|
-
|
98
|
-
expect{s2.recv(32)}.to raise_exception(Async::TimeoutError, "execution expired")
|
99
|
-
|
100
|
-
s1.close
|
101
|
-
s2.close
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe '.pair' do
|
106
|
-
subject{described_class.pair(:UNIX, :STREAM, 0)}
|
107
|
-
|
108
|
-
it "should be able to send and recv" do
|
109
|
-
s1, s2 = *subject
|
110
|
-
|
111
|
-
s1.send "Hello World", 0
|
112
|
-
s1.close
|
113
|
-
|
114
|
-
expect(s2.recv(32)).to be == "Hello World"
|
115
|
-
s2.close
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should be connected" do
|
119
|
-
s1, s2 = *subject
|
120
|
-
|
121
|
-
expect(s1).to be_connected
|
122
|
-
|
123
|
-
s1.close
|
124
|
-
|
125
|
-
expect(s2).to_not be_connected
|
126
|
-
|
127
|
-
s2.close
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context '.pipe' do
|
132
|
-
let(:sockets) do
|
133
|
-
@sockets = described_class.pair(Socket::AF_UNIX, Socket::SOCK_STREAM)
|
134
|
-
end
|
135
|
-
|
136
|
-
after do
|
137
|
-
@sockets&.each(&:close)
|
138
|
-
end
|
139
|
-
|
140
|
-
let(:io) {sockets.first}
|
141
|
-
subject {sockets.last}
|
142
|
-
|
143
|
-
it_should_behave_like Async::IO
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
RSpec.describe Async::IO::IPSocket do
|
148
|
-
it_should_behave_like Async::IO::Generic, [:inspect]
|
149
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'async/io/ssl_socket'
|
24
|
-
require 'async/io/ssl_endpoint'
|
25
|
-
|
26
|
-
require 'async/rspec/ssl'
|
27
|
-
require_relative 'generic_examples'
|
28
|
-
|
29
|
-
RSpec.describe Async::IO::SSLServer do
|
30
|
-
include_context Async::RSpec::Reactor
|
31
|
-
|
32
|
-
context 'single host' do
|
33
|
-
include_context Async::RSpec::SSL::VerifiedContexts
|
34
|
-
include_context Async::RSpec::SSL::ValidCertificate
|
35
|
-
|
36
|
-
let(:endpoint) {Async::IO::Endpoint.tcp("127.0.0.1", 6780, reuse_port: true)}
|
37
|
-
let(:server_endpoint) {Async::IO::SSLEndpoint.new(endpoint, ssl_context: server_context)}
|
38
|
-
let(:client_endpoint) {Async::IO::SSLEndpoint.new(endpoint, ssl_context: client_context)}
|
39
|
-
|
40
|
-
let(:data) {"What one programmer can do in one month, two programmers can do in two months."}
|
41
|
-
|
42
|
-
it "can see through to address" do
|
43
|
-
expect(server_endpoint.address).to be == endpoint.address
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'can accept_each connections' do
|
47
|
-
# Accept a single incoming connection and then finish.
|
48
|
-
server_task = reactor.async do |task|
|
49
|
-
server_endpoint.bind do |server|
|
50
|
-
server.listen(10)
|
51
|
-
|
52
|
-
server.accept_each do |peer, address|
|
53
|
-
data = peer.read(512)
|
54
|
-
peer.write(data)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
reactor.async do
|
60
|
-
client_endpoint.connect do |client|
|
61
|
-
client.write(data)
|
62
|
-
client.close_write
|
63
|
-
|
64
|
-
expect(client.read(512)).to be == data
|
65
|
-
end
|
66
|
-
|
67
|
-
server_task.stop
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'multiple hosts' do
|
73
|
-
let(:hosts) {['test.com', 'example.com']}
|
74
|
-
|
75
|
-
include_context Async::RSpec::SSL::HostCertificates
|
76
|
-
|
77
|
-
let(:endpoint) {Async::IO::Endpoint.tcp("127.0.0.1", 6782, reuse_port: true)}
|
78
|
-
let(:server_endpoint) {Async::IO::SSLEndpoint.new(endpoint, ssl_context: server_context)}
|
79
|
-
let(:valid_client_endpoint) {Async::IO::SSLEndpoint.new(endpoint, hostname: 'example.com', ssl_context: client_context)}
|
80
|
-
let(:invalid_client_endpoint) {Async::IO::SSLEndpoint.new(endpoint, hostname: 'fleeb.com', ssl_context: client_context)}
|
81
|
-
|
82
|
-
let(:data) {"What one programmer can do in one month, two programmers can do in two months."}
|
83
|
-
|
84
|
-
it 'can select correct host' do
|
85
|
-
# Accept a single incoming connection and then finish.
|
86
|
-
server_task = reactor.async do |task|
|
87
|
-
server_endpoint.bind do |server|
|
88
|
-
server.listen(10)
|
89
|
-
|
90
|
-
server.accept_each do |peer, address|
|
91
|
-
expect(peer.hostname).to be == 'example.com'
|
92
|
-
|
93
|
-
data = peer.read(512)
|
94
|
-
peer.write(data)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
reactor.async do
|
100
|
-
valid_client_endpoint.connect do |client|
|
101
|
-
client.write(data)
|
102
|
-
client.close_write
|
103
|
-
|
104
|
-
expect(client.read(512)).to be == data
|
105
|
-
end
|
106
|
-
|
107
|
-
server_task.stop
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'it fails with invalid host' do
|
112
|
-
# Accept a single incoming connection and then finish.
|
113
|
-
server_task = reactor.async do |task|
|
114
|
-
server_endpoint.bind do |server|
|
115
|
-
server.listen(10)
|
116
|
-
|
117
|
-
server.accept_each do |peer, address|
|
118
|
-
peer.close
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
reactor.async do
|
124
|
-
expect do
|
125
|
-
invalid_client_endpoint.connect do |client|
|
126
|
-
end
|
127
|
-
end.to raise_exception(OpenSSL::SSL::SSLError, /handshake failure/)
|
128
|
-
|
129
|
-
server_task.stop
|
130
|
-
end.wait
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|