From e9434ebce1f1c4ae628faf34123ec7ae261f8fe8 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Fri, 6 Feb 2026 11:46:35 +0000 Subject: [PATCH 1/2] set last_stream_id after activating stream always this fixes an issue where a PRIORITY frame does not set it, and a GOAWAY frame may be sent with the wrong last_stream id --- lib/http/2/connection.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/http/2/connection.rb b/lib/http/2/connection.rb index d3cf180..40a7c13 100644 --- a/lib/http/2/connection.rb +++ b/lib/http/2/connection.rb @@ -129,7 +129,6 @@ def new_stream(**args) connection_error(:protocol_error, msg: "id is smaller than previous") if @stream_id < @last_stream_id stream = activate_stream(id: @stream_id, **args) - @last_stream_id = stream.id @stream_id += 2 @@ -766,6 +765,7 @@ def activate_stream(id:, **args) raise StreamLimitExceeded if @active_stream_count >= @local_settings[:settings_max_concurrent_streams] stream = Stream.new(connection: self, id: id, **args) + @last_stream_id = id stream.once(:close) do @streams.delete(id) @@ -799,7 +799,6 @@ def verify_stream_order(id) return unless id.odd? connection_error(msg: "Stream ID smaller than previous") if @last_stream_id >= id - @last_stream_id = id end def _verify_pseudo_headers(frame, mandatory_headers) From 2f9c5f14fd282b1003c98c692b466797f86655d2 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Fri, 6 Feb 2026 11:48:08 +0000 Subject: [PATCH 2/2] allow send buffers to be cleared in a case where the connection user wants to react to a peer goaway by cleaning up the buffer waiting on processing --- lib/http/2/flow_buffer.rb | 5 +++++ sig/frame_buffer.rbs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/http/2/flow_buffer.rb b/lib/http/2/flow_buffer.rb index ecf19eb..56fb2e1 100644 --- a/lib/http/2/flow_buffer.rb +++ b/lib/http/2/flow_buffer.rb @@ -122,6 +122,11 @@ def initialize @bytesize = 0 end + def clear + @buffer.clear + @bytesize = 0 + end + def <<(frame) @buffer << frame @bytesize += frame[:payload].bytesize diff --git a/sig/frame_buffer.rbs b/sig/frame_buffer.rbs index 8dbaaed..57cb53f 100644 --- a/sig/frame_buffer.rbs +++ b/sig/frame_buffer.rbs @@ -4,6 +4,8 @@ module HTTP2 @buffer: Array[data_frame] + def clear: () -> void + def <<: (data_frame frame) -> void def empty?: () -> bool