Skip to content

Commit a104ab6

Browse files
committed
Fix maximum_connection_streams -> @remote_settings.
1 parent 79e2283 commit a104ab6

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lib/protocol/http2/connection.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ def maximum_frame_size
6262
@remote_settings.maximum_frame_size
6363
end
6464

65+
# The maximum number of concurrent streams that this connection can initiate:
6566
def maximum_concurrent_streams
66-
@local_settings.maximum_concurrent_streams
67+
@remote_settings.maximum_concurrent_streams
6768
end
6869

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

392-
if @streams.size < self.maximum_concurrent_streams
393+
# We need to validate that we have less streams than the specified maximum:
394+
if @streams.size < @local_settings.maximum_concurrent_streams
393395
stream = accept_stream(stream_id)
394396
@remote_stream_id = stream_id
395397

test/protocol/http2/connection.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@
1111
let(:framer) {Protocol::HTTP2::Framer.new(stream)}
1212
let(:connection) {subject.new(framer, 1)}
1313

14+
with "#maximum_concurrent_streams" do
15+
it "is the remote peer's maximum concurrent streams" do
16+
connection.remote_settings.maximum_concurrent_streams = 10
17+
connection.local_settings.current.maximum_concurrent_streams = 5
18+
19+
expect(connection.maximum_concurrent_streams).to be == 10
20+
end
21+
end
22+
23+
with '#receive_headers' do
24+
it "fails with protocol error if exceeding the maximum concurrent connections" do
25+
connection.local_settings.current.maximum_concurrent_streams = 1
26+
# Create a stream to
27+
connection.streams[1] = Protocol::HTTP2::Stream.new(connection, 1)
28+
29+
frame = Protocol::HTTP2::HeadersFrame.new(3)
30+
31+
expect do
32+
connection.receive_headers(frame)
33+
end.to raise_exception(Protocol::HTTP2::ProtocolError, message: be =~ /Exceeded maximum concurrent streams/)
34+
end
35+
end
36+
1437
it "reports the connection id 0 is not closed" do
1538
expect(connection).not.to be(:closed_stream_id?, 0)
1639
end

0 commit comments

Comments
 (0)