Skip to content

fix error value when opening a new stream #1299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2025
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