diff options
author | James Newton-King <james@newtonking.com> | 2022-08-02 06:30:17 +0300 |
---|---|---|
committer | James Newton-King <james@newtonking.com> | 2022-08-02 06:30:17 +0300 |
commit | 2b3302ec49275c5c0a0ceb7d156603e0d275aa89 (patch) | |
tree | 97df077ce5fe4ec5b27e7263b2481ea59fb3b7f8 | |
parent | a1a0056f603a1fc4bc07650dfab8489a225c1286 (diff) |
Add testjamesnk/http3-dynamicport
-rw-r--r-- | src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs | 3 | ||||
-rw-r--r-- | src/Servers/Kestrel/Transport.Quic/test/WebHostTests.cs | 36 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs b/src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs index d6ef8b5ffb..a95d853828 100644 --- a/src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs +++ b/src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs @@ -218,7 +218,8 @@ internal sealed class KestrelServerImpl : IServer if (hasHttp3 && _multiplexedTransportFactory is not null) { - // The + // Check if a previous transport has changed the endpoint. If it has then the endpoint is dynamic and we can't guarantee it will work for other transports. + // For more details, see https://github.com/dotnet/aspnetcore/issues/42982 if (!configuredEndpoint.Equals(options.EndPoint)) { Trace.LogError(CoreStrings.DynamicPortOnMultipleTransportsNotSupported); diff --git a/src/Servers/Kestrel/Transport.Quic/test/WebHostTests.cs b/src/Servers/Kestrel/Transport.Quic/test/WebHostTests.cs index 259cc7532d..159e516eca 100644 --- a/src/Servers/Kestrel/Transport.Quic/test/WebHostTests.cs +++ b/src/Servers/Kestrel/Transport.Quic/test/WebHostTests.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Internal; +using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -132,6 +133,41 @@ public class WebHostTests : LoggedTest [ConditionalFact] [MsQuicSupported] + public async Task Listen_Http3AndSocketsOnDynamicEndpoint_Http3Disabled() + { + // Arrange + var builder = new HostBuilder() + .ConfigureWebHost(webHostBuilder => + { + webHostBuilder + .UseKestrel(o => + { + o.Listen(IPAddress.Parse("127.0.0.1"), 0, listenOptions => + { + listenOptions.Protocols = Core.HttpProtocols.Http1AndHttp2AndHttp3; + listenOptions.UseHttps(TestResources.GetTestCertificate()); + }); + }) + .Configure(app => + { + app.Run(async context => + { + await context.Response.WriteAsync("hello, world"); + }); + }); + }) + .ConfigureServices(AddTestLogging); + + using var host = builder.Build(); + await host.StartAsync().DefaultTimeout(); + + Assert.Contains(TestSink.Writes, w => w.Message == CoreStrings.DynamicPortOnMultipleTransportsNotSupported); + + await host.StopAsync().DefaultTimeout(); + } + + [ConditionalFact] + [MsQuicSupported] public async Task Listen_Http3AndSocketsCoexistOnSameEndpoint_ClientSuccess() { await BindPortsWithRetry(async port => |