async-websocket 0.19.1 → 0.21.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
- checksums.yaml.gz.sig +0 -0
- data/lib/async/websocket/adapters/http.rb +12 -5
- data/lib/async/websocket/adapters/rack.rb +9 -16
- data/lib/async/websocket/client.rb +18 -5
- data/lib/async/websocket/connect_request.rb +2 -3
- data/lib/async/websocket/connect_response.rb +1 -1
- data/lib/async/websocket/connection.rb +7 -1
- data/lib/async/websocket/response.rb +1 -1
- data/lib/async/websocket/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +44 -29
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f647aa6496d73f12e3fb60e2f0973f1021c0e9ed4184285114182e726644ed2
|
4
|
+
data.tar.gz: 2263444a6dea430fcf6ffe1f39a25c05a8bcdfb3e27cb54abd334b69bcadf918
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1545f3675a0168932cfa393d24fcc68332e254c3e279e9db35c7c0478b5d541d6dd293ab0e2dfb76cc52fd5bc55c8a157ecc4e2283150ab44c814d5b791ef4eb
|
7
|
+
data.tar.gz: 3b28edd7eeef1ba6f1f89ffc05cead77f9fdcd85dc79d85d11cdafc65b85d98c4f1bed7bd9a019b71fdc0ce4ff5f1a6ab8b844844a3c75715c64987988c645d4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -23,6 +23,8 @@
|
|
23
23
|
require_relative '../connection'
|
24
24
|
require_relative '../response'
|
25
25
|
|
26
|
+
require 'protocol/websocket/extensions'
|
27
|
+
|
26
28
|
module Async
|
27
29
|
module WebSocket
|
28
30
|
module Adapters
|
@@ -33,19 +35,24 @@ module Async
|
|
33
35
|
Array(request.protocol).any? { |e| e.casecmp?(PROTOCOL) }
|
34
36
|
end
|
35
37
|
|
36
|
-
def self.open(request, headers: [], protocols: [], handler: Connection, **options, &block)
|
38
|
+
def self.open(request, headers: [], protocols: [], handler: Connection, extensions: ::Protocol::WebSocket::Extensions::Server.default, **options, &block)
|
37
39
|
if websocket?(request)
|
40
|
+
headers = Protocol::HTTP::Headers[headers]
|
41
|
+
|
38
42
|
# Select websocket sub-protocol:
|
39
43
|
if requested_protocol = request.headers[SEC_WEBSOCKET_PROTOCOL]
|
40
44
|
protocol = (requested_protocol & protocols).first
|
41
45
|
end
|
42
46
|
|
47
|
+
if extensions and extension_headers = request.headers[SEC_WEBSOCKET_EXTENSIONS]
|
48
|
+
extensions.accept(extension_headers) do |header|
|
49
|
+
headers.add(SEC_WEBSOCKET_EXTENSIONS, header.join(";"))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
43
53
|
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
54
|
framer = Protocol::WebSocket::Framer.new(stream)
|
48
|
-
connection = handler.call(framer, protocol)
|
55
|
+
connection = handler.call(framer, protocol, extensions)
|
49
56
|
|
50
57
|
yield connection
|
51
58
|
|
@@ -21,6 +21,7 @@
|
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
23
|
require_relative 'http'
|
24
|
+
require 'protocol/rack/request'
|
24
25
|
|
25
26
|
module Async
|
26
27
|
module WebSocket
|
@@ -29,27 +30,19 @@ module Async
|
|
29
30
|
include ::Protocol::WebSocket::Headers
|
30
31
|
|
31
32
|
def self.websocket?(env)
|
32
|
-
|
33
|
+
HTTP.websocket?(
|
34
|
+
::Protocol::Rack::Request[env]
|
35
|
+
)
|
33
36
|
end
|
34
37
|
|
35
38
|
def self.open(env, **options, &block)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
headers = response.headers
|
41
|
-
|
42
|
-
if protocol = response.protocol
|
43
|
-
headers = Protocol::HTTP::Headers::Merged.new(headers, [
|
44
|
-
['rack.protocol', protocol]
|
45
|
-
])
|
46
|
-
end
|
47
|
-
|
48
|
-
return [response.status, headers.to_h, response.body]
|
49
|
-
end
|
39
|
+
request = ::Protocol::Rack::Request[env]
|
40
|
+
|
41
|
+
if response = HTTP.open(request, **options, &block)
|
42
|
+
return Protocol::Rack::Adapter.make_response(env, response)
|
50
43
|
end
|
51
44
|
end
|
52
45
|
end
|
53
46
|
end
|
54
47
|
end
|
55
|
-
end
|
48
|
+
end
|
@@ -24,6 +24,7 @@ require_relative 'request'
|
|
24
24
|
require_relative 'connection'
|
25
25
|
|
26
26
|
require 'protocol/websocket/headers'
|
27
|
+
require 'protocol/websocket/extensions'
|
27
28
|
require 'protocol/http/middleware'
|
28
29
|
|
29
30
|
require 'async/http/client'
|
@@ -48,8 +49,8 @@ module Async
|
|
48
49
|
end
|
49
50
|
|
50
51
|
# @return [Connection] an open websocket connection to the given endpoint.
|
51
|
-
def self.connect(endpoint, *
|
52
|
-
client = self.open(endpoint, *
|
52
|
+
def self.connect(endpoint, *arguments, **options, &block)
|
53
|
+
client = self.open(endpoint, *arguments)
|
53
54
|
connection = client.connect(endpoint.authority, endpoint.path, **options)
|
54
55
|
|
55
56
|
return connection unless block_given?
|
@@ -86,8 +87,13 @@ module Async
|
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
89
|
-
def connect(authority, path, headers: nil, handler: Connection, **options, &block)
|
90
|
+
def connect(authority, path, headers: nil, handler: Connection, extensions: ::Protocol::WebSocket::Extensions::Client.default, **options, &block)
|
90
91
|
headers = ::Protocol::HTTP::Headers[headers]
|
92
|
+
|
93
|
+
extensions&.offer do |extension|
|
94
|
+
headers.add(SEC_WEBSOCKET_EXTENSIONS, extension.join("; "))
|
95
|
+
end
|
96
|
+
|
91
97
|
request = Request.new(nil, authority, path, headers, **options)
|
92
98
|
|
93
99
|
pool = @delegate.pool
|
@@ -101,12 +107,19 @@ module Async
|
|
101
107
|
|
102
108
|
protocol = response.headers[SEC_WEBSOCKET_PROTOCOL]&.first
|
103
109
|
stream = response.stream
|
104
|
-
response = nil
|
105
110
|
|
106
111
|
framer = Framer.new(pool, connection, stream)
|
112
|
+
|
107
113
|
connection = nil
|
108
114
|
|
109
|
-
|
115
|
+
if extension_headers = response.headers[SEC_WEBSOCKET_EXTENSIONS]
|
116
|
+
extensions.accept(extension_headers)
|
117
|
+
end
|
118
|
+
|
119
|
+
response = nil
|
120
|
+
stream = nil
|
121
|
+
|
122
|
+
connction = handler.call(framer, protocol, extensions, **@options, &block)
|
110
123
|
ensure
|
111
124
|
pool.release(connection) if connection
|
112
125
|
end
|
@@ -23,8 +23,7 @@
|
|
23
23
|
require 'protocol/http/request'
|
24
24
|
require 'protocol/http/headers'
|
25
25
|
require 'protocol/websocket/headers'
|
26
|
-
|
27
|
-
require 'async/http/body/stream'
|
26
|
+
require 'protocol/http/body/readable'
|
28
27
|
|
29
28
|
module Async
|
30
29
|
module WebSocket
|
@@ -66,7 +65,7 @@ module Async
|
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
69
|
-
class Hijack <
|
68
|
+
class Hijack < Protocol::HTTP::Body::Readable
|
70
69
|
def initialize(request)
|
71
70
|
@request = request
|
72
71
|
@stream = nil
|
@@ -31,9 +31,11 @@ module Async
|
|
31
31
|
class Connection < ::Protocol::WebSocket::Connection
|
32
32
|
include ::Protocol::WebSocket::Headers
|
33
33
|
|
34
|
-
def self.call(framer, protocol = [], **options)
|
34
|
+
def self.call(framer, protocol = [], extensions = nil, **options)
|
35
35
|
instance = self.new(framer, Array(protocol).first, **options)
|
36
36
|
|
37
|
+
extensions&.apply(instance)
|
38
|
+
|
37
39
|
return instance unless block_given?
|
38
40
|
|
39
41
|
begin
|
@@ -50,6 +52,10 @@ module Async
|
|
50
52
|
@response = response
|
51
53
|
end
|
52
54
|
|
55
|
+
def reusable?
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
53
59
|
def close
|
54
60
|
super
|
55
61
|
|
@@ -30,7 +30,7 @@ module Async
|
|
30
30
|
def self.for(request, headers = nil, **options, &body)
|
31
31
|
if request.version =~ /http\/1/i
|
32
32
|
return UpgradeResponse.new(request, headers, **options, &body)
|
33
|
-
elsif request.version =~ /
|
33
|
+
elsif request.version =~ /http\/2/i
|
34
34
|
return ConnectResponse.new(request, headers, **options, &body)
|
35
35
|
end
|
36
36
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-websocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -18,33 +18,34 @@ bindir: bin
|
|
18
18
|
cert_chain:
|
19
19
|
- |
|
20
20
|
-----BEGIN CERTIFICATE-----
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
21
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
22
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
23
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
24
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
25
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJ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
|
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=
|
46
47
|
-----END CERTIFICATE-----
|
47
|
-
date: 2022-08-
|
48
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
48
49
|
dependencies:
|
49
50
|
- !ruby/object:Gem::Dependency
|
50
51
|
name: async-http
|
@@ -74,20 +75,34 @@ dependencies:
|
|
74
75
|
- - "~>"
|
75
76
|
- !ruby/object:Gem::Version
|
76
77
|
version: '1.23'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: protocol-rack
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.1.1
|
85
|
+
type: :runtime
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.1.1
|
77
92
|
- !ruby/object:Gem::Dependency
|
78
93
|
name: protocol-websocket
|
79
94
|
requirement: !ruby/object:Gem::Requirement
|
80
95
|
requirements:
|
81
96
|
- - "~>"
|
82
97
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.
|
98
|
+
version: 0.8.0
|
84
99
|
type: :runtime
|
85
100
|
prerelease: false
|
86
101
|
version_requirements: !ruby/object:Gem::Requirement
|
87
102
|
requirements:
|
88
103
|
- - "~>"
|
89
104
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
105
|
+
version: 0.8.0
|
91
106
|
- !ruby/object:Gem::Dependency
|
92
107
|
name: async-rspec
|
93
108
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|