Skip to content

Turn HTTP/3 on by default in Kestrel #44217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/src/ListenOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core;
/// </summary>
public class ListenOptions : IConnectionBuilder, IMultiplexedConnectionBuilder
{
internal const HttpProtocols DefaultHttpProtocols = HttpProtocols.Http1AndHttp2;
internal const HttpProtocols DefaultHttpProtocols = HttpProtocols.Http1AndHttp2AndHttp3;

internal readonly List<Func<ConnectionDelegate, ConnectionDelegate>> _middleware = new List<Func<ConnectionDelegate, ConnectionDelegate>>();
internal readonly List<Func<MultiplexedConnectionDelegate, MultiplexedConnectionDelegate>> _multiplexedMiddleware = new List<Func<MultiplexedConnectionDelegate, MultiplexedConnectionDelegate>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void ConfigureEndpointDefaultsAppliesToNewEndpoints()
var options = new KestrelServerOptions();
options.ListenLocalhost(5000);

Assert.Equal(HttpProtocols.Http1AndHttp2, options.CodeBackedListenOptions[0].Protocols);
Assert.Equal(ListenOptions.DefaultHttpProtocols, options.CodeBackedListenOptions[0].Protocols);

options.ConfigureEndpointDefaults(opt =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/test/ListenOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ListenOptionsTests
public void ProtocolsDefault()
{
var listenOptions = new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0));
Assert.Equal(HttpProtocols.Http1AndHttp2, listenOptions.Protocols);
Assert.Equal(ListenOptions.DefaultHttpProtocols, listenOptions.Protocols);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ private void EndpointConfigSectionCanSetProtocols(string input, HttpProtocols ex
serverOptions.ConfigureEndpointDefaults(opt =>
{
// Kestrel default.
Assert.Equal(HttpProtocols.Http1AndHttp2, opt.Protocols);
Assert.Equal(ListenOptions.DefaultHttpProtocols, opt.Protocols);
ranDefault = true;
});

Expand Down Expand Up @@ -663,14 +663,14 @@ private void EndpointConfigSectionCanSetProtocols(string input, HttpProtocols ex
.LocalhostEndpoint(5002, opt =>
{
// Kestrel default.
Assert.Equal(HttpProtocols.Http1AndHttp2, opt.Protocols);
Assert.Equal(ListenOptions.DefaultHttpProtocols, opt.Protocols);
ran2 = true;
})
.Load();
serverOptions.ListenAnyIP(0, opt =>
{
// Kestrel default.
Assert.Equal(HttpProtocols.Http1AndHttp2, opt.Protocols);
Assert.Equal(ListenOptions.DefaultHttpProtocols, opt.Protocols);
ran3 = true;
});

Expand Down Expand Up @@ -1038,13 +1038,15 @@ public void Reload_IdentifiesEndpointsWithChangedDefaults()

var (endpointsToStop, endpointsToStart) = serverOptions.ConfigurationLoader.Reload();

Assert.Single(endpointsToStop);
Assert.Single(endpointsToStart);
// NonDefaultProtocol is unchanged and doesn't need to be stopped/started
var stopEndpoint = Assert.Single(endpointsToStop);
var startEndpoint = Assert.Single(endpointsToStart);

Assert.Equal(5000, stopEndpoint.IPEndPoint.Port);
Assert.Equal(ListenOptions.DefaultHttpProtocols, stopEndpoint.Protocols);

Assert.Equal(5000, endpointsToStop[0].IPEndPoint.Port);
Assert.Equal(HttpProtocols.Http1AndHttp2, endpointsToStop[0].Protocols);
Assert.Equal(5000, endpointsToStart[0].IPEndPoint.Port);
Assert.Equal(HttpProtocols.Http1, endpointsToStart[0].Protocols);
Assert.Equal(5000, startEndpoint.IPEndPoint.Port);
Assert.Equal(HttpProtocols.Http1, startEndpoint.Protocols);
}

[Fact]
Expand Down