protocol-http2 0.16.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http2/connection.rb +26 -5
- data/lib/protocol/http2/framer.rb +11 -7
- data/lib/protocol/http2/server.rb +4 -2
- data/lib/protocol/http2/version.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +7 -5
- 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: d3d7de9d5cea0bc568ee4cfe9c36ec1857d3e268b5b183bda0602fb66862faf3
|
4
|
+
data.tar.gz: 2a5e7b2fae05cb3ff96cc821160f745e80ffd45eef1363ea99c4c029853f5073
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15841f05ca83452964396dd3e9b2c7d0f7dd456d38495772545e3a57b1991a589a3fb68b99721c3303af76318dde23b8d8839242310da172b5ef715efcc0da61
|
7
|
+
data.tar.gz: 7148bc4ba24d364960beee692fce5f7be577bc147045ae1a829cb26b64c363501307359b998c16e36bd6bcfcfb6a2405f7f93d4ed8db2c231b5a1be814792fd9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2023, by Marco Concetto Rudilosso.
|
6
6
|
|
7
7
|
require_relative 'framer'
|
@@ -62,8 +62,9 @@ module Protocol
|
|
62
62
|
@remote_settings.maximum_frame_size
|
63
63
|
end
|
64
64
|
|
65
|
+
# The maximum number of concurrent streams that this connection can initiate:
|
65
66
|
def maximum_concurrent_streams
|
66
|
-
@
|
67
|
+
@remote_settings.maximum_concurrent_streams
|
67
68
|
end
|
68
69
|
|
69
70
|
attr :framer
|
@@ -143,9 +144,14 @@ module Protocol
|
|
143
144
|
end
|
144
145
|
end
|
145
146
|
|
147
|
+
def synchronize
|
148
|
+
yield
|
149
|
+
end
|
150
|
+
|
146
151
|
# Reads one frame from the network and processes. Processing the frame updates the state of the connection and related streams. If the frame triggers an error, e.g. a protocol error, the connection will typically emit a goaway frame and re-raise the exception. You should continue processing frames until the underlying connection is closed.
|
147
152
|
def read_frame
|
148
153
|
frame = @framer.read_frame(@local_settings.maximum_frame_size)
|
154
|
+
|
149
155
|
# puts "#{self.class} #{@state} read_frame: class=#{frame.class} stream_id=#{frame.stream_id} flags=#{frame.flags} length=#{frame.length} (remote_stream_id=#{@remote_stream_id})"
|
150
156
|
# puts "Windows: local_window=#{@local_window.inspect}; remote_window=#{@remote_window.inspect}"
|
151
157
|
|
@@ -207,11 +213,25 @@ module Protocol
|
|
207
213
|
end
|
208
214
|
|
209
215
|
def write_frame(frame)
|
210
|
-
|
216
|
+
synchronize do
|
217
|
+
@framer.write_frame(frame)
|
218
|
+
end
|
219
|
+
|
220
|
+
# The IO is already synchronized, and we don't want additional contention.
|
221
|
+
@framer.flush
|
211
222
|
end
|
212
223
|
|
213
224
|
def write_frames
|
214
|
-
|
225
|
+
if @framer
|
226
|
+
synchronize do
|
227
|
+
yield @framer
|
228
|
+
end
|
229
|
+
|
230
|
+
# See above note.
|
231
|
+
@framer.flush
|
232
|
+
else
|
233
|
+
raise EOFError, "Connection closed!"
|
234
|
+
end
|
215
235
|
end
|
216
236
|
|
217
237
|
def update_local_settings(changes)
|
@@ -370,7 +390,8 @@ module Protocol
|
|
370
390
|
raise ProtocolError, "Invalid stream id: #{stream_id} <= #{@remote_stream_id}!"
|
371
391
|
end
|
372
392
|
|
373
|
-
|
393
|
+
# We need to validate that we have less streams than the specified maximum:
|
394
|
+
if @streams.size < @local_settings.maximum_concurrent_streams
|
374
395
|
stream = accept_stream(stream_id)
|
375
396
|
@remote_stream_id = stream_id
|
376
397
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative 'error'
|
7
7
|
|
@@ -41,6 +41,10 @@ module Protocol
|
|
41
41
|
@frames = frames
|
42
42
|
end
|
43
43
|
|
44
|
+
def flush
|
45
|
+
@stream.flush
|
46
|
+
end
|
47
|
+
|
44
48
|
def close
|
45
49
|
@stream.close
|
46
50
|
end
|
@@ -69,7 +73,7 @@ module Protocol
|
|
69
73
|
# Read the header:
|
70
74
|
length, type, flags, stream_id = read_header
|
71
75
|
|
72
|
-
#
|
76
|
+
# Console.debug(self) {"read_frame: length=#{length} type=#{type} flags=#{flags} stream_id=#{stream_id} -> klass=#{@frames[type].inspect}"}
|
73
77
|
|
74
78
|
# Allocate the frame:
|
75
79
|
klass = @frames[type] || Frame
|
@@ -78,19 +82,19 @@ module Protocol
|
|
78
82
|
# Read the payload:
|
79
83
|
frame.read(@stream, maximum_frame_size)
|
80
84
|
|
81
|
-
#
|
85
|
+
# Console.debug(self, name: "read") {frame.inspect}
|
82
86
|
|
83
87
|
return frame
|
84
88
|
end
|
85
89
|
|
90
|
+
# Write a frame to the underlying IO.
|
91
|
+
# After writing one or more frames, you should call flush to ensure the frames are sent to the remote peer.
|
92
|
+
# @parameter frame [Frame] the frame to write.
|
86
93
|
def write_frame(frame)
|
87
|
-
#
|
94
|
+
# Console.debug(self, name: "write") {frame.inspect}
|
88
95
|
|
89
96
|
frame.write(@stream)
|
90
97
|
|
91
|
-
# Don't call @stream.flush here because it can cause significant contention if there is a semaphore around this method.
|
92
|
-
# @stream.flush
|
93
|
-
|
94
98
|
return frame
|
95
99
|
end
|
96
100
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative 'connection'
|
7
7
|
|
@@ -31,7 +31,9 @@ module Protocol
|
|
31
31
|
send_settings(settings)
|
32
32
|
|
33
33
|
read_frame do |frame|
|
34
|
-
|
34
|
+
unless frame.is_a? SettingsFrame
|
35
|
+
raise ProtocolError, "First frame must be #{SettingsFrame}, but got #{frame.class}"
|
36
|
+
end
|
35
37
|
end
|
36
38
|
else
|
37
39
|
raise ProtocolError, "Cannot read connection preface in state #{@state}"
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-http2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -40,7 +40,7 @@ cert_chain:
|
|
40
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
41
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
42
42
|
-----END CERTIFICATE-----
|
43
|
-
date: 2024-
|
43
|
+
date: 2024-06-10 00:00:00.000000000 Z
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: protocol-hpack
|
@@ -103,7 +103,9 @@ files:
|
|
103
103
|
homepage: https://github.com/socketry/protocol-http2
|
104
104
|
licenses:
|
105
105
|
- MIT
|
106
|
-
metadata:
|
106
|
+
metadata:
|
107
|
+
documentation_uri: https://socketry.github.io/protocol-http2/
|
108
|
+
source_code_uri: https://github.com/socketry/protocol-http2.git
|
107
109
|
post_install_message:
|
108
110
|
rdoc_options: []
|
109
111
|
require_paths:
|
@@ -112,14 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
114
|
requirements:
|
113
115
|
- - ">="
|
114
116
|
- !ruby/object:Gem::Version
|
115
|
-
version: '3.
|
117
|
+
version: '3.1'
|
116
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
119
|
requirements:
|
118
120
|
- - ">="
|
119
121
|
- !ruby/object:Gem::Version
|
120
122
|
version: '0'
|
121
123
|
requirements: []
|
122
|
-
rubygems_version: 3.5.
|
124
|
+
rubygems_version: 3.5.9
|
123
125
|
signing_key:
|
124
126
|
specification_version: 4
|
125
127
|
summary: A low level implementation of the HTTP/2 protocol.
|
metadata.gz.sig
CHANGED
Binary file
|