I think somewhat similar should happen with normal winhttp requests (I was doing some brief tests around that back then) and that should hopefully be easy to add incrementally after this patchset.
Then, sends for websockets should most likely also be cancelled the same way although that is a bit harder to test as most of the time sends are processed right away before returing from WinHttpWebSocketSend (although should be possible as out of tree test which might be flaky).
The patches here address cancelling web socket receive operation (including receiving web socket close status).
-- v2: winhttp/tests: Add tests for closing web socket with pending operations. winhttp: Support abort in task_socket_close(). winhttp: Abort websocket IO on handle close. winhttp: Replace pending read cancel in WinHttpWebSocketClose() with a generic cancel_queue(). winhttp: Fix dwResult field in websocket receive error result. winhttp: Implement reference counting for tasks. winhttp: Keep task in queue until completion.