async-websocket 0.18.0 → 0.19.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: 54e97832ebcebab09dfd5a042aad8532a7a5277cf6609fecae9f73a1826cac7d
4
- data.tar.gz: 671da6e463ced51447b8cb49aabbb8b51d644a19adc655e9f955fe4b6772afd4
3
+ metadata.gz: 4494a49f3ddda2ac524f29eb3d7c9819441f8816532f4e2650f4a375580cac5a
4
+ data.tar.gz: 93d249315220fc12d1619ed02e0706ce5c24f6591fb820c6f8894e6f8009e877
5
5
  SHA512:
6
- metadata.gz: c33efe4ce32ddf75596defe2b3c3f56bb05973d1c13e4b9c39e9fbaed604c9774271b6dd88db11691ba1a498b3c3ee807e6aa3a54447a30ea3ba791d8818388b
7
- data.tar.gz: 50b6419551ee9643771cb80dbd7ad48460e265f3e8a168e60f4afa9557802eb4bc2543b5cb678e55b81ccf006679bfa865047e590f5f7b99526f0dd628bc3005
6
+ metadata.gz: 3c66caf1da58fb21136cdbdbd9c7d4342b270b65d524578eaa8821f15877f081324fd7c74aa22c16d7a062ea4e7a926c8baa6ab8bdcb111f45a4bd111d999f29
7
+ data.tar.gz: 1ee636003a5962dea1ed85465bb2cd4447b3589d51cca1b11df6f473f7a54ae348bc0a94ded3aab66bb9ba6a78083157ce29ca6a08ce3b39c345d28573f7ae75
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,64 @@
1
+ # frozen_string_literals: true
2
+ #
3
+ # Copyright, 2019, 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_relative '../connection'
24
+ require_relative '../response'
25
+
26
+ module Async
27
+ module WebSocket
28
+ module Adapters
29
+ module HTTP
30
+ include ::Protocol::WebSocket::Headers
31
+
32
+ def self.websocket?(request)
33
+ Array(request.protocol).any? { |e| e.casecmp?(PROTOCOL) }
34
+ end
35
+
36
+ def self.open(request, headers: [], protocols: [], handler: Connection, **options, &block)
37
+ if websocket?(request)
38
+ # Select websocket sub-protocol:
39
+ if requested_protocol = request.headers[SEC_WEBSOCKET_PROTOCOL]
40
+ protocol = (requested_protocol & protocols).first
41
+ end
42
+
43
+ response = Response.for(request, headers, protocol: protocol, **options) do |stream|
44
+ # Once we get to this point, we no longer need to hold on to the response:
45
+ response = nil
46
+
47
+ framer = Protocol::WebSocket::Framer.new(stream)
48
+ connection = handler.call(framer, protocol)
49
+
50
+ yield connection
51
+
52
+ connection.close unless connection.closed?
53
+ end
54
+
55
+ # Once we get to this point, we no longer need to hold on to the request:
56
+ request = nil
57
+
58
+ return response
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -20,8 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
- require_relative '../connection'
24
- require_relative '../response'
23
+ require_relative 'http'
25
24
 
26
25
  module Async
27
26
  module WebSocket
@@ -33,37 +32,21 @@ module Async
33
32
  request = env['async.http.request'] and Array(request.protocol).include?(PROTOCOL)
34
33
  end
35
34
 
36
- def self.open(env, headers: [], protocols: [], handler: Connection, **options, &block)
37
- if request = env['async.http.request'] and Array(request.protocol).include?(PROTOCOL)
35
+ def self.open(env, **options, &block)
36
+ if request = env['async.http.request']
38
37
  env = nil
39
38
 
40
- # Select websocket sub-protocol:
41
- if requested_protocol = request.headers[SEC_WEBSOCKET_PROTOCOL]
42
- protocol = (requested_protocol & protocols).first
43
- end
44
-
45
- response = Response.for(request, headers, protocol: protocol, **options) do |stream|
46
- response = nil
47
-
48
- framer = Protocol::WebSocket::Framer.new(stream)
49
-
50
- connection = handler.call(framer, protocol)
39
+ if response = HTTP.open(request, **options, &block)
40
+ headers = response.headers
51
41
 
52
- yield connection
42
+ if protocol = response.protocol
43
+ headers = Protocol::HTTP::Headers::Merged.new(headers, [
44
+ ['rack.protocol', protocol]
45
+ ])
46
+ end
53
47
 
54
- connection.close unless connection.closed?
48
+ return [response.status, headers.to_h, response.body]
55
49
  end
56
-
57
- request = nil
58
- headers = response.headers
59
-
60
- if protocol = response.protocol
61
- headers = Protocol::HTTP::Headers::Merged.new(headers, [
62
- ['rack.protocol', protocol]
63
- ])
64
- end
65
-
66
- return [response.status, headers.to_h, response.body]
67
50
  end
68
51
  end
69
52
  end
@@ -49,16 +49,16 @@ module Async
49
49
 
50
50
  # @return [Connection] an open websocket connection to the given endpoint.
51
51
  def self.connect(endpoint, *args, **options, &block)
52
- self.open(endpoint, *args) do |client|
53
- connection = client.connect(endpoint.authority, endpoint.path, **options)
52
+ client = self.open(endpoint, *args)
53
+ connection = client.connect(endpoint.authority, endpoint.path, **options)
54
54
 
55
- return connection unless block_given?
55
+ return connection unless block_given?
56
56
 
57
- begin
58
- yield connection
59
- ensure
60
- connection.close
61
- end
57
+ begin
58
+ yield connection
59
+ ensure
60
+ connection.close
61
+ client.close
62
62
  end
63
63
  end
64
64
 
@@ -24,8 +24,6 @@ require 'protocol/http/request'
24
24
  require 'protocol/http/headers'
25
25
  require 'protocol/websocket/headers'
26
26
 
27
- require 'async/http/body/stream'
28
-
29
27
  module Async
30
28
  module WebSocket
31
29
  # This is required for HTTP/1.x to upgrade the connection to the WebSocket protocol.
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module WebSocket
23
- VERSION = "0.18.0"
23
+ VERSION = "0.19.2"
24
24
  end
25
25
  end
data.tar.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ W�^���kIJ���Y�zw ���3�14���*����-��z��QZ���������g����~��y�Ϊ|Im�������Y�P�Z�G�Z?xI��:i8���ڜ�y0`q��v�?N�W��
2
+ �=.���3����J����i�TJK
3
+ B��V����M2@Ok��ѡ��kY�G���x���N�+&�ۮ2����(� 4��N
metadata CHANGED
@@ -1,14 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - destructobeam
9
+ - Olle Jonsson
10
+ - Aurora
11
+ - Bryan Powell
12
+ - Gleb Sinyavskiy
13
+ - Janko Marohnić
14
+ - Michel Boaventura
15
+ - jaml
8
16
  autorequire:
9
17
  bindir: bin
10
- cert_chain: []
11
- date: 2021-04-21 00:00:00.000000000 Z
18
+ cert_chain:
19
+ - |
20
+ -----BEGIN CERTIFICATE-----
21
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
22
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
23
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/Is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xkE
39
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
40
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
41
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
42
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
43
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
44
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
45
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
46
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
47
+ -----END CERTIFICATE-----
48
+ date: 2022-08-07 00:00:00.000000000 Z
12
49
  dependencies:
13
50
  - !ruby/object:Gem::Dependency
14
51
  name: async-http
@@ -143,6 +180,7 @@ extensions: []
143
180
  extra_rdoc_files: []
144
181
  files:
145
182
  - lib/async/websocket.rb
183
+ - lib/async/websocket/adapters/http.rb
146
184
  - lib/async/websocket/adapters/rack.rb
147
185
  - lib/async/websocket/adapters/rails.rb
148
186
  - lib/async/websocket/client.rb
@@ -176,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
214
  - !ruby/object:Gem::Version
177
215
  version: '0'
178
216
  requirements: []
179
- rubygems_version: 3.1.2
217
+ rubygems_version: 3.3.7
180
218
  signing_key:
181
219
  specification_version: 4
182
220
  summary: An async websocket library on top of websocket-driver.
metadata.gz.sig ADDED
Binary file