Skip to content

Commit 3525ace

Browse files
authored
Add Retry and Task.Delay to WinHttpHandler AfterReadResponseServerError_ClientWrite test (#90824)
* Add Task.Delay to give more time for reset frame * Apply @JamesNK' solution
1 parent 3c3f499 commit 3525ace

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,17 @@ public async Task AfterReadResponseServerError_ClientWrite()
143143
// Server sends RST_STREAM.
144144
await connection.WriteFrameAsync(new RstStreamFrame(FrameFlags.EndStream, 0, streamId));
145145

146-
await Assert.ThrowsAsync<IOException>(() => requestStream.WriteAsync(new byte[50]).AsTask());
146+
await Assert.ThrowsAsync<IOException>(async () =>
147+
{
148+
for (int i = 0; i < 10; i++)
149+
{
150+
await requestStream.WriteAsync(new byte[50]);
151+
152+
// WriteAsync succeeded because handler hasn't processed RST_STREAM yet.
153+
// Small wait before trying again.
154+
await Task.Delay(50);
155+
}
156+
});
147157
}
148158
}
149159

0 commit comments

Comments
 (0)