File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,9 @@ def maximum_frame_size
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
66
def maximum_concurrent_streams
66
- @local_settings . maximum_concurrent_streams
67
+ @remote_settings . maximum_concurrent_streams
67
68
end
68
69
69
70
attr :framer
@@ -389,7 +390,8 @@ def receive_headers(frame)
389
390
raise ProtocolError , "Invalid stream id: #{ stream_id } <= #{ @remote_stream_id } !"
390
391
end
391
392
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
393
395
stream = accept_stream ( stream_id )
394
396
@remote_stream_id = stream_id
395
397
Original file line number Diff line number Diff line change 11
11
let ( :framer ) { Protocol ::HTTP2 ::Framer . new ( stream ) }
12
12
let ( :connection ) { subject . new ( framer , 1 ) }
13
13
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
+
14
37
it "reports the connection id 0 is not closed" do
15
38
expect ( connection ) . not . to be ( :closed_stream_id? , 0 )
16
39
end
You can’t perform that action at this time.
0 commit comments