[release/8.0] Add Retry and Task.Delay to WinHttpHandler AfterReadResponseServerError...
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 29 Aug 2023 17:15:34 +0000 (10:15 -0700)
committerGitHub <noreply@github.com>
Tue, 29 Aug 2023 17:15:34 +0000 (10:15 -0700)
* Add Task.Delay to give more time for reset frame

* Apply James' solution

---------

Co-authored-by: Ahmet Ibrahim Aksoy (from Dev Box) <aaksoy@microsoft.com>
src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs

index d18de54..ce79f20 100644 (file)
@@ -143,7 +143,17 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
                 // Server sends RST_STREAM.
                 await connection.WriteFrameAsync(new RstStreamFrame(FrameFlags.EndStream, 0, streamId));
 
-                await Assert.ThrowsAsync<IOException>(() => requestStream.WriteAsync(new byte[50]).AsTask());
+                await Assert.ThrowsAsync<IOException>(async () =>
+                {
+                    for (int i = 0; i < 10; i++)
+                    {
+                        await requestStream.WriteAsync(new byte[50]);
+
+                        // WriteAsync succeeded because handler hasn't processed RST_STREAM yet.
+                        // Small wait before trying again.
+                        await Task.Delay(50);
+                    }
+                });
             }
         }