Skip to content

Commit 700990e

Browse files
joaquin-borggio-lcKriechi
authored andcommitted
fix: Raise more informative error instead of generic KeyError on end_stream
1 parent fd69c3b commit 700990e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/h2/connection.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,14 @@ def end_stream(self, stream_id: int) -> None:
919919
:param stream_id: The ID of the stream to end.
920920
:type stream_id: ``int``
921921
:returns: Nothing
922+
:raises NoSuchStreamError: If the stream ID does not correspond to a
923+
known stream and is higher than the current maximum stream ID.
924+
:raises StreamClosedError: If the stream ID corresponds to a stream
925+
that has been closed.
922926
"""
923927
self.config.logger.debug("End stream ID %d", stream_id)
924928
self.state_machine.process_input(ConnectionInputs.SEND_DATA)
925-
frames = self.streams[stream_id].end_stream()
929+
frames = self._get_stream_by_id(stream_id).end_stream()
926930
self._prepare_for_sending(frames)
927931

928932
def increment_flow_control_window(self, increment: int, stream_id: int | None = None) -> None:

0 commit comments

Comments
 (0)