protocol-http2 0.19.4 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b04111afb8bcb89c8866ccd13f1782ab2cd9ccf438210d5da17aecb384d2cf02
4
- data.tar.gz: 7574a7a9595487e5ad574250e98a6662e5d2c588acffe8536b9d4f642cabfc4b
3
+ metadata.gz: 80a795de54c7f452a70b82f310c4f0aa3bda4bd15f034f548114a41bfc8d1649
4
+ data.tar.gz: 496e203587367c71ce4b0298ba96492d5ce4892842fdcbf57796031556ca3f1a
5
5
  SHA512:
6
- metadata.gz: ec243f9398ad359deb1ca97341d6fca6c563158a40fa7e3617b39af599bb0ebce8c302ef7af3a378b944d1b8ada1689eff8f540e5c274a065fcd2c8420f531af
7
- data.tar.gz: '08f92272a802133333232cac14b26568fdc5e95b4c0054caec717de403e0a5e22d41d3c2aa57ec08af40de11a75e4f2bb508d1b7b4c480513da81d352d58c072'
6
+ metadata.gz: e4b587ae75dc73dbd99ff3bc20cafe6c55cb329ab275bac187572730de5d5365f2f8c521d88b32bffb80363736cf0cdc62d579d2495872f13982b4f1cd1fdfa0
7
+ data.tar.gz: f2964d07b204b702ded73b1a3df961dad07c95989e78311732d4264184b59a6671f7bb81511e1d196c1dd9ccf18f81db1fd8064607c3156550191dc7cec8a5d2
checksums.yaml.gz.sig CHANGED
Binary file
@@ -62,7 +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
+ # The maximum number of concurrent streams that this connection can initiate. This is a setting that can be changed by the remote peer.
66
+ #
67
+ # It is not the same as the number of streams that can be accepted by the connection. The number of streams that can be accepted is determined by the local settings, and the number of streams that can be initiated is determined by the remote settings.
66
68
  def maximum_concurrent_streams
67
69
  @remote_settings.maximum_concurrent_streams
68
70
  end
@@ -58,6 +58,10 @@ module Protocol
58
58
  @weight <=> other.weight
59
59
  end
60
60
 
61
+ def == other
62
+ @id == other.id
63
+ end
64
+
61
65
  # The connection this stream belongs to.
62
66
  attr :connection
63
67
 
@@ -101,13 +105,30 @@ module Protocol
101
105
 
102
106
  dependency.parent = self
103
107
 
104
- self.clear_cache!
108
+ if @ordered_children
109
+ # Binary search for insertion point:
110
+ index = @ordered_children.bsearch_index do |child|
111
+ child.weight >= dependency.weight
112
+ end
113
+
114
+ if index
115
+ @ordered_children.insert(index, dependency)
116
+ else
117
+ @ordered_children.push(dependency)
118
+ end
119
+
120
+ @total_weight += dependency.weight
121
+ end
105
122
  end
106
123
 
107
124
  def remove_child(dependency)
108
125
  @children&.delete(dependency.id)
109
126
 
110
- self.clear_cache!
127
+ if @ordered_children
128
+ # Don't do a linear search here, it can be slow. Instead, the child's parent will be set to `nil`, and we check this in {#consume_window} using `delete_if`.
129
+ # @ordered_children.delete(dependency)
130
+ @total_weight -= dependency.weight
131
+ end
111
132
  end
112
133
 
113
134
  # An exclusive flag allows for the insertion of a new level of dependencies. The exclusive flag causes the stream to become the sole dependency of its parent stream, causing other dependencies to become dependent on the exclusive stream.
@@ -195,11 +216,17 @@ module Protocol
195
216
  end
196
217
 
197
218
  # Otherwise, allow the dependent children to use up the available window:
198
- self.ordered_children&.each do |child|
199
- # Compute the proportional allocation:
200
- allocated = (child.weight * size) / @total_weight
201
-
202
- child.consume_window(allocated) if allocated > 0
219
+ self.ordered_children&.delete_if do |child|
220
+ if child.parent
221
+ # Compute the proportional allocation:
222
+ allocated = (child.weight * size) / @total_weight
223
+
224
+ child.consume_window(allocated) if allocated > 0
225
+
226
+ false
227
+ else
228
+ true
229
+ end
203
230
  end
204
231
  end
205
232
 
@@ -16,8 +16,6 @@ require_relative "goaway_frame"
16
16
  require_relative "window_update_frame"
17
17
  require_relative "continuation_frame"
18
18
 
19
- require "traces/provider"
20
-
21
19
  module Protocol
22
20
  module HTTP2
23
21
  # HTTP/2 frame type mapping as defined by the spec
@@ -109,50 +107,6 @@ module Protocol
109
107
 
110
108
  raise EOFError, "Could not read frame header!"
111
109
  end
112
-
113
- Traces::Provider(self) do
114
- def write_connection_preface
115
- Traces.trace("protocol.http2.framer.write_connection_preface") do
116
- super
117
- end
118
- end
119
-
120
- def read_connection_preface
121
- Traces.trace("protocol.http2.framer.read_connection_preface") do
122
- super
123
- end
124
- end
125
-
126
- def write_frame(frame)
127
- attributes = {
128
- "frame.length" => frame.length,
129
- "frame.type" => frame.type,
130
- "frame.flags" => frame.flags,
131
- "frame.stream_id" => frame.stream_id,
132
- }
133
-
134
- Traces.trace("protocol.http2.framer.write_frame", attributes: attributes) do
135
- super
136
- end
137
- end
138
-
139
- def read_frame(maximum_frame_size = MAXIMUM_ALLOWED_FRAME_SIZE)
140
- Traces.trace("protocol.http2.framer.read_frame") do |span|
141
- super.tap do |frame|
142
- span["frame.length"] = frame.length
143
- span["frame.type"] = frame.type
144
- span["frame.flags"] = frame.flags
145
- span["frame.stream_id"] = frame.stream_id
146
- end
147
- end
148
- end
149
-
150
- def flush
151
- Traces.trace("protocol.http2.framer.flush") do
152
- super
153
- end
154
- end
155
- end
156
110
  end
157
111
  end
158
112
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP2
8
- VERSION = "0.19.4"
8
+ VERSION = "0.20.0"
9
9
  end
10
10
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ require "traces/provider"
7
+ require_relative "../../../../protocol/http2/framer"
8
+
9
+ Traces::Provider(Protocol::HTTP2::Framer) do
10
+ def write_connection_preface
11
+ Traces.trace("protocol.http2.framer.write_connection_preface") do
12
+ super
13
+ end
14
+ end
15
+
16
+ def read_connection_preface
17
+ Traces.trace("protocol.http2.framer.read_connection_preface") do
18
+ super
19
+ end
20
+ end
21
+
22
+ def write_frame(frame)
23
+ attributes = {
24
+ "frame.length" => frame.length,
25
+ "frame.class" => frame.class.name,
26
+ "frame.type" => frame.type,
27
+ "frame.flags" => frame.flags,
28
+ "frame.stream_id" => frame.stream_id,
29
+ }
30
+
31
+ Traces.trace("protocol.http2.framer.write_frame", attributes: attributes) do
32
+ super
33
+ end
34
+ end
35
+
36
+ def read_frame(...)
37
+ Traces.trace("protocol.http2.framer.read_frame") do |span|
38
+ super.tap do |frame|
39
+ span["frame.length"] = frame.length
40
+ span["frame.type"] = frame.type
41
+ span["frame.flags"] = frame.flags
42
+ span["frame.stream_id"] = frame.stream_id
43
+ end
44
+ end
45
+ end
46
+
47
+ def flush
48
+ Traces.trace("protocol.http2.framer.flush") do
49
+ super
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ require_relative "http2/framer"
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.19.4
4
+ version: 0.20.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-11-03 00:00:00.000000000 Z
43
+ date: 2024-11-09 00:00:00.000000000 Z
44
44
  dependencies:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: protocol-hpack
@@ -70,20 +70,6 @@ dependencies:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0.18'
73
- - !ruby/object:Gem::Dependency
74
- name: traces
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- type: :runtime
81
- prerelease: false
82
- version_requirements: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: '0'
87
73
  description:
88
74
  email:
89
75
  executables: []
@@ -113,6 +99,8 @@ files:
113
99
  - lib/protocol/http2/version.rb
114
100
  - lib/protocol/http2/window.rb
115
101
  - lib/protocol/http2/window_update_frame.rb
102
+ - lib/traces/provider/protocol/http2.rb
103
+ - lib/traces/provider/protocol/http2/framer.rb
116
104
  - license.md
117
105
  - readme.md
118
106
  homepage: https://github.com/socketry/protocol-http2
@@ -136,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
124
  - !ruby/object:Gem::Version
137
125
  version: '0'
138
126
  requirements: []
139
- rubygems_version: 3.5.11
127
+ rubygems_version: 3.5.22
140
128
  signing_key:
141
129
  specification_version: 4
142
130
  summary: A low level implementation of the HTTP/2 protocol.
metadata.gz.sig CHANGED
Binary file