Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/h2/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,9 @@ def send_headers(self,
# Check we can open the stream.
if stream_id not in self.streams:
max_open_streams = self.remote_settings.max_concurrent_streams
if (self.open_outbound_streams + 1) > max_open_streams:
msg = f"Max outbound streams is {max_open_streams}, {self.open_outbound_streams} open"
value = self.open_outbound_streams # take a copy due to the property accessor having side affects
if (value + 1) > max_open_streams:
msg = f"Max outbound streams is {max_open_streams}, {value} open"
raise TooManyStreamsError(msg)

self.state_machine.process_input(ConnectionInputs.SEND_HEADERS)
Expand Down Expand Up @@ -1593,8 +1594,9 @@ def _receive_headers_frame(self, frame: HeadersFrame) -> tuple[list[Frame], list
# stream ID is valid.
if frame.stream_id not in self.streams:
max_open_streams = self.local_settings.max_concurrent_streams
if (self.open_inbound_streams + 1) > max_open_streams:
msg = f"Max outbound streams is {max_open_streams}, {self.open_outbound_streams} open"
value = self.open_inbound_streams # take a copy due to the property accessor having side affects
if (value + 1) > max_open_streams:
msg = f"Max inbound streams is {max_open_streams}, {value} open"
raise TooManyStreamsError(msg)

# Let's decode the headers. We handle headers as bytes internally up
Expand Down