Skip to content

Commit

Permalink
fix(h2_connection_reset): add stream reset when client cancel the req…
Browse files Browse the repository at this point in the history
…uest
  • Loading branch information
MarkLux committed Aug 19, 2024
1 parent 7d87c9d commit 7455935
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions httpcore/_async/http2.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,12 @@ async def _receive_remote_settings_change(self, event: h2.events.Event) -> None:
async def _response_closed(self, stream_id: int) -> None:
await self._max_streams_semaphore.release()
del self._events[stream_id]

stream = self._h2_state._get_stream_by_id(stream_id=stream_id)
if stream and not stream.closed:
# stream closed by client cancel, send a RstStream frame with CancelCode to server
self._h2_state.reset_stream(stream_id=stream_id, error_code=h2.settings.ErrorCodes.CANCEL)

async with self._state_lock:
if self._connection_terminated and not self._events:
await self.aclose()
Expand Down

0 comments on commit 7455935

Please sign in to comment.