Skip to content

Commit 2bc5964

Browse files
Maaarcocrioquatix
authored andcommitted
Maximum concurrent stream is defined only by the local settings.
1 parent 014f415 commit 2bc5964

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

lib/protocol/http2/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def maximum_frame_size
7777
end
7878

7979
def maximum_concurrent_streams
80-
[@local_settings.maximum_concurrent_streams, @remote_settings.maximum_concurrent_streams].min
80+
@local_settings.maximum_concurrent_streams
8181
end
8282

8383
attr :framer

spec/protocol/http2/connection_spec.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,52 @@
189189
expect(frame).to be_end_stream
190190
end
191191
end
192+
193+
it "allows client to create new stream and send headers when client maximum concurrent streams is 0" do
194+
client.local_settings.current.maximum_concurrent_streams = 0
195+
client_stream = client.create_stream
196+
request_headers = [[':method', 'GET'], [':path', '/'], [':authority', 'localhost']]
197+
client_stream.send_headers(nil, request_headers)
198+
199+
expect(server).to receive(:receive_headers).once.and_wrap_original do |method, frame|
200+
headers = method.call(frame)
201+
202+
expect(headers).to be == request_headers
203+
end
204+
205+
server.read_frame
206+
end
207+
208+
it "does not allow client to create new stream and send headers when server maximum concurrent streams is 0" do
209+
server.local_settings.current.maximum_concurrent_streams = 0
210+
client_stream = client.create_stream
211+
request_headers = [[':method', 'GET'], [':path', '/'], [':authority', 'localhost']]
212+
client_stream.send_headers(nil, request_headers)
213+
214+
expect { server.read_frame }.to raise_error(Protocol::HTTP2::ProtocolError)
215+
end
216+
217+
it "allows server to create new stream and send headers when server maximum concurrent streams is 0" do
218+
server.local_settings.current.maximum_concurrent_streams = 0
219+
server_stream = server.create_stream
220+
request_headers = [[':method', 'GET'], [':path', '/'], [':authority', 'localhost']]
221+
server_stream.send_headers(nil, request_headers)
222+
223+
expect(client).to receive(:receive_headers).once.and_wrap_original do |method, frame|
224+
headers = method.call(frame)
225+
226+
expect(headers).to be == request_headers
227+
end
228+
229+
client.read_frame
230+
end
231+
232+
it "does not allow server to create new stream send headers when client maximum concurrent streams is 0" do
233+
client.local_settings.current.maximum_concurrent_streams = 0
234+
server_stream = server.create_stream
235+
request_headers = [[':method', 'GET'], [':path', '/'], [':authority', 'localhost']]
236+
server_stream.send_headers(nil, request_headers)
237+
238+
expect { client.read_frame }.to raise_error(Protocol::HTTP2::ProtocolError)
239+
end
192240
end

0 commit comments

Comments
 (0)