Skip to content

Commit 7455935

Browse files
committed
fix(h2_connection_reset): add stream reset when client cancel the request
1 parent 7d87c9d commit 7455935

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

httpcore/_async/http2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ async def _receive_remote_settings_change(self, event: h2.events.Event) -> None:
404404
async def _response_closed(self, stream_id: int) -> None:
405405
await self._max_streams_semaphore.release()
406406
del self._events[stream_id]
407+
408+
stream = self._h2_state._get_stream_by_id(stream_id=stream_id)
409+
if stream and not stream.closed:
410+
# stream closed by client cancel, send a RstStream frame with CancelCode to server
411+
self._h2_state.reset_stream(stream_id=stream_id, error_code=h2.settings.ErrorCodes.CANCEL)
412+
407413
async with self._state_lock:
408414
if self._connection_terminated and not self._events:
409415
await self.aclose()

0 commit comments

Comments
 (0)