async-io 1.16.1 → 1.16.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 379d35c46cafb056a9ad45909ba233b60c2494fcf2c822e114d6e4fecb489417
4
- data.tar.gz: f6a5aa2014a2af8164517d3f25147d3a041b04fcc3180d271af07c6724e60aad
3
+ metadata.gz: 75f6a63033122d073826af1192a8993d1ecfca0e78820b60421f95dadaac2fea
4
+ data.tar.gz: d2f32d91cda9e88a1a366a9a072a62e118a7427019b643a5ef2946ac0a8b55e5
5
5
  SHA512:
6
- metadata.gz: ce284102e8f3c8dd0b107f6d0958aff37e4aeafb71784c77b4e647e19f05346543b9f2e7d4fc738f29a45a88fa7e69e2d8df687f3325dd4a5f42c1b4ce03cc13
7
- data.tar.gz: b1f090f450cce626da8b04169bd04c3a21c87184295d3bd52c157d69df336aa50ac136b7e19b09010945fc575855f7e7eaa9bd12b3408785898d2a333f5dfb06
6
+ metadata.gz: 402f1ba7007d6c24fbd963ada3bdd7ba4d37a82075ab38029ef09bf640b7107469be94d94c6dddd3376fb42fafaa8197eb403d272c6eb97b70ef121903c29c24
7
+ data.tar.gz: 3f72a92843d27ad462b940e34af302e7f0903c023382fdc379f7170988a9fdbfa71edba0f26cc347b8dcaeea5fb9164eeaafc0af474ce0558e0061e93e91061d
data/Gemfile CHANGED
@@ -19,4 +19,6 @@ group :test do
19
19
  gem 'coveralls', require: false
20
20
 
21
21
  gem 'async-container'
22
+
23
+ gem 'http'
22
24
  end
@@ -19,6 +19,8 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  require 'socket'
22
+ require 'async/task'
23
+
22
24
  require_relative 'generic'
23
25
 
24
26
  module Async
@@ -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.wrap(socket, context)
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 self.wrap(socket, context)
76
- io = @wrapped_klass.new(socket.to_io, context)
77
-
78
- # We detach the socket from the reactor, otherwise it's possible to add the file descriptor to the selector twice, which is bad.
79
- socket.reactor = nil
80
-
81
- # This ensures that when the internal IO is closed, it also closes the internal socket:
82
- io.sync_close = true
83
-
84
- return self.new(io, socket.reactor)
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.wrap(peer, @context)
117
+ wrapper = SSLSocket.new(peer, @context)
114
118
 
115
119
  return wrapper, address unless block_given?
116
120
 
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module IO
23
- VERSION = "1.16.1"
23
+ VERSION = "1.16.2"
24
24
  end
25
25
  end
@@ -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.1
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-03 00:00:00.000000000 Z
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