Skip to content

Commit

Permalink
fix error value when opening a new stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Kriechi committed Feb 13, 2025
1 parent c6ed27c commit 59909db
Showing 1 changed file with 6 additions and 4 deletions.
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_inbound_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 outbound streams is {max_open_streams}, {value} open"
raise TooManyStreamsError(msg)

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

0 comments on commit 59909db

Please sign in to comment.