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) 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