Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ public async Task POST_ClientSendsOnlyHeaders_RequestReceivedOnServer(HttpProtoc
}
}

[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/52573")]
[ConditionalTheory]
[MsQuicSupported]
[InlineData(HttpProtocols.Http3)]
Expand All @@ -324,6 +323,21 @@ public async Task POST_MultipleRequests_PooledStreamAndHeaders(HttpProtocols pro
// Arrange
string contentType = null;
string authority = null;
var pooledTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
Action<WriteContext> handler = null;
if (protocol == HttpProtocols.Http3)
{
handler = ctx =>
{
if (ctx.EventId.Name == "StreamPooled" &&
ctx.LoggerName == "Microsoft.AspNetCore.Server.Kestrel.Transport.Quic")
{
pooledTcs.TrySetResult();
}
};
TestSink.MessageLogged += handler;
}
Comment thread
Vinoth2562000 marked this conversation as resolved.
Outdated

var builder = CreateHostBuilder(async context =>
{
contentType = context.Request.ContentType;
Expand All @@ -333,38 +347,47 @@ public async Task POST_MultipleRequests_PooledStreamAndHeaders(HttpProtocols pro
await context.Response.Body.WriteAsync(data);
}, protocol: protocol);

using (var host = builder.Build())
using (var client = HttpHelpers.CreateClient())
try
{
await host.StartAsync();
using (var host = builder.Build())
using (var client = HttpHelpers.CreateClient())
{
await host.StartAsync();

// Act
var response1 = await SendRequestAsync(protocol, host, client);
var contentType1 = contentType;
var authority1 = authority;
// Act
var response1 = await SendRequestAsync(protocol, host, client);
var contentType1 = contentType;
var authority1 = authority;

if (protocol == HttpProtocols.Http3)
{
await WaitForLogAsync(logs =>
if (protocol == HttpProtocols.Http3)
{
return logs.Any(w => w.LoggerName == "Microsoft.AspNetCore.Server.Kestrel.Transport.Quic" &&
w.EventId.Name == "StreamPooled");
}, "Wait for server to finish pooling stream.");
}
// Wait for the server to pool the first request's stream before sending
// the second request, so the second request reuses the same
// HttpRequestHeaders instance and Assert.Same below holds.
await pooledTcs.Task.DefaultTimeout();
}

var response2 = await SendRequestAsync(protocol, host, client);
var contentType2 = contentType;
var authority2 = authority;
var response2 = await SendRequestAsync(protocol, host, client);
var contentType2 = contentType;
var authority2 = authority;

// Assert
Assert.NotNull(contentType1);
Assert.NotNull(authority1);
// Assert
Assert.NotNull(contentType1);
Assert.NotNull(authority1);

// We're testing `Same`, specifically, since we're trying to detect cache misses
Assert.Same(contentType1, contentType2);
Assert.Same(authority1, authority2);
// We're testing `Same`, specifically, since we're trying to detect cache misses
Assert.Same(contentType1, contentType2);
Assert.Same(authority1, authority2);

await host.StopAsync();
await host.StopAsync();
}
}
finally
{
if (handler != null)
{
TestSink.MessageLogged -= handler;
}
}

static async Task<HttpResponseMessage> SendRequestAsync(HttpProtocols protocol, IHost host, HttpMessageInvoker client)
Expand Down
Loading