We have a bunch of cancellation tests in HttpClientHandlerTest.Cancellation.cs that validate that requests can be cancelled on the client. But none of these are actually validating that the server is properly notified of the cancellation, via the HTTP version specific mechanism (like RST_STREAM for HTTP2).
The loopback server WaitForCancellationAsync method was added to do exactly this -- validate that the server sees the client's cancellation. But currently none of these tests use it. We should modify these tests to use it, which should both (a) simplify some of the test logic (hopefully) and (b) validate that we are cancelling properly on the wire in all cases.
(The only case in which we use WaitForCancellationAsync is in a request finalization test, which sort of makes sense since the only way to actually verify finalization is to observe the behavior on the wire.)
Note that WinHttpHandler seems to aggressively send RST on request cancellation for HTTP/1.1, so we will need to modify the HTTP/1.1 implementation of WaitForCancellationAsync to allow RST.
Related issues:
#58234
#58235