async-io 1.16.1 → 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/async/io/socket.rb +2 -0
- data/lib/async/io/ssl_socket.rb +16 -12
- data/lib/async/io/version.rb +1 -1
- data/spec/async/io/wrap/http_rb_spec.rb +45 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75f6a63033122d073826af1192a8993d1ecfca0e78820b60421f95dadaac2fea
|
4
|
+
data.tar.gz: d2f32d91cda9e88a1a366a9a072a62e118a7427019b643a5ef2946ac0a8b55e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 402f1ba7007d6c24fbd963ada3bdd7ba4d37a82075ab38029ef09bf640b7107469be94d94c6dddd3376fb42fafaa8197eb403d272c6eb97b70ef121903c29c24
|
7
|
+
data.tar.gz: 3f72a92843d27ad462b940e34af302e7f0903c023382fdc379f7170988a9fdbfa71edba0f26cc347b8dcaeea5fb9164eeaafc0af474ce0558e0061e93e91061d
|
data/Gemfile
CHANGED
data/lib/async/io/socket.rb
CHANGED
data/lib/async/io/ssl_socket.rb
CHANGED
@@ -37,7 +37,7 @@ module Async
|
|
37
37
|
alias sysread read
|
38
38
|
|
39
39
|
def self.connect(socket, context, hostname = nil, &block)
|
40
|
-
client = self.
|
40
|
+
client = self.new(socket, context)
|
41
41
|
|
42
42
|
# Used for SNI:
|
43
43
|
if hostname
|
@@ -72,16 +72,20 @@ module Async
|
|
72
72
|
|
73
73
|
include Peer
|
74
74
|
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
75
|
+
def initialize(socket, context)
|
76
|
+
if socket.is_a?(self.class.wrapped_klass)
|
77
|
+
super
|
78
|
+
else
|
79
|
+
io = self.class.wrapped_klass.new(socket.to_io, context)
|
80
|
+
|
81
|
+
# We detach the socket from the reactor, otherwise it's possible to add the file descriptor to the selector twice, which is bad.
|
82
|
+
socket.reactor = nil
|
83
|
+
|
84
|
+
# This ensures that when the internal IO is closed, it also closes the internal socket:
|
85
|
+
io.sync_close = true
|
86
|
+
|
87
|
+
super(io, socket.reactor)
|
88
|
+
end
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
@@ -110,7 +114,7 @@ module Async
|
|
110
114
|
def accept(task: Task.current)
|
111
115
|
peer, address = @server.accept
|
112
116
|
|
113
|
-
wrapper = SSLSocket.
|
117
|
+
wrapper = SSLSocket.new(peer, @context)
|
114
118
|
|
115
119
|
return wrapper, address unless block_given?
|
116
120
|
|
data/lib/async/io/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright, 2018, by Thibaut Girka.
|
2
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'http'
|
23
|
+
require 'openssl'
|
24
|
+
|
25
|
+
require 'async/io/tcp_socket'
|
26
|
+
require 'async/io/ssl_socket'
|
27
|
+
|
28
|
+
RSpec.describe Async::IO do
|
29
|
+
let(:wrappers) do
|
30
|
+
{socket_class: Async::IO::TCPSocket, ssl_socket_class: Async::IO::SSLSocket}
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "inside reactor" do
|
34
|
+
include_context Async::RSpec::Reactor
|
35
|
+
|
36
|
+
it "should fetch page" do
|
37
|
+
expect(Async::IO::SSLSocket).to receive(:new).and_call_original
|
38
|
+
|
39
|
+
expect do
|
40
|
+
response = HTTP.get('https://www.google.com', wrappers)
|
41
|
+
response.connection.close
|
42
|
+
end.to_not raise_error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- spec/async/io/trap_spec.rb
|
148
148
|
- spec/async/io/udp_socket_spec.rb
|
149
149
|
- spec/async/io/unix_socket_spec.rb
|
150
|
+
- spec/async/io/wrap/http_rb_spec.rb
|
150
151
|
- spec/async/io/wrap/tcp_spec.rb
|
151
152
|
- spec/spec_helper.rb
|
152
153
|
homepage: https://github.com/socketry/async-io
|
@@ -195,5 +196,6 @@ test_files:
|
|
195
196
|
- spec/async/io/trap_spec.rb
|
196
197
|
- spec/async/io/udp_socket_spec.rb
|
197
198
|
- spec/async/io/unix_socket_spec.rb
|
199
|
+
- spec/async/io/wrap/http_rb_spec.rb
|
198
200
|
- spec/async/io/wrap/tcp_spec.rb
|
199
201
|
- spec/spec_helper.rb
|