Skip to content

Commit

Permalink
Fix maximum_connection_streams -> @remote_settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 10, 2024
1 parent 4356975 commit c260c95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/protocol/http2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def maximum_frame_size
@remote_settings.maximum_frame_size
end

# The maximum number of concurrent streams that this connection can initiate:
def maximum_concurrent_streams
@local_settings.maximum_concurrent_streams
@remote_settings.maximum_concurrent_streams
end

attr :framer
Expand Down Expand Up @@ -389,7 +390,8 @@ def receive_headers(frame)
raise ProtocolError, "Invalid stream id: #{stream_id} <= #{@remote_stream_id}!"
end

if @streams.size < self.maximum_concurrent_streams
# We need to validate that we have less streams than the specified maximum:
if @streams.size < @local_settings.maximum_concurrent_streams
stream = accept_stream(stream_id)
@remote_stream_id = stream_id

Expand Down
9 changes: 9 additions & 0 deletions test/protocol/http2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
let(:framer) {Protocol::HTTP2::Framer.new(stream)}
let(:connection) {subject.new(framer, 1)}

with "#maximum_concurrent_streams" do
it "is the remote peer's maximum concurrent streams" do
connection.remote_settings.maximum_concurrent_streams = 10
connection.local_settings.current.maximum_concurrent_streams = 5

expect(connection.maximum_concurrent_streams).to be == 10
end
end

it "reports the connection id 0 is not closed" do
expect(connection).not.to be(:closed_stream_id?, 0)
end
Expand Down

0 comments on commit c260c95

Please sign in to comment.