Skip to content

Commit 88f9987

Browse files
author
ladeak
committed
Same concern addressed in MultipleWrites_HeaderFrame
1 parent 4ce05af commit 88f9987

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tests/CHttpServer.Tests/Http3/Http3StreamTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,24 @@ public async Task MultipleWrites_HeaderFrame()
5656

5757
TaskCompletionSource tcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
5858
sut.Initialize(null, await serverStreamTask);
59-
var testApp = new TestBase.TestApplication(ctx =>
59+
var testApp = new TestBase.TestApplication(async ctx =>
6060
{
6161
Assert.Equal("/", ctx.Request.Path);
6262
Assert.Equal("https", ctx.Request.Scheme);
6363
Assert.Equal("localhost", ctx.Request.Host.ToString());
6464
Assert.Equal(HttpMethod.Get.ToString(), ctx.Request.Method);
65-
tcs.SetResult();
66-
return Task.CompletedTask;
65+
66+
// This callback shall not complete before the 2nd flush, otherwise the
67+
// server might close the stream before the flush succeeds.
68+
await tcs.Task;
6769
});
6870
var processing = sut.ProcessStreamAsync(testApp, TestContext.Current.CancellationToken);
6971

7072
// Second Write
7173
await clientStream.WriteAsync(headersFrame[i..], TestContext.Current.CancellationToken);
7274
await clientStream.FlushAsync(TestContext.Current.CancellationToken);
75+
tcs.SetResult();
7376

74-
await tcs.Task.WaitAsync(DefaultTimeout, TestContext.Current.CancellationToken);
7577
clientStream.Close();
7678
await processing;
7779
await quicConnection.DisposeAsync();

0 commit comments

Comments
 (0)