Skip to content

Commit 90327cd

Browse files
authored
Refactor quic setup (dotnet#34877)
1 parent fab0234 commit 90327cd

24 files changed

+268
-123
lines changed

AspNetCore.sln

+15
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logging.W3C.Sample", "src\M
16361636
EndProject
16371637
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Razor.Internal.SourceGenerator.Transport", "src\Razor\Microsoft.AspNetCore.Razor.Internal.SourceGenerator.Transport\Microsoft.AspNetCore.Razor.Internal.SourceGenerator.Transport.csproj", "{247E7B6F-FBA2-41A9-BA03-C7C4DF28091C}"
16381638
EndProject
1639+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HttpClientApp", "src\Servers\Kestrel\samples\HttpClientApp\HttpClientApp.csproj", "{514726D2-3D2E-44C1-B056-163E37DE3E8B}"
1640+
EndProject
16391641
Global
16401642
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16411643
Debug|Any CPU = Debug|Any CPU
@@ -7803,6 +7805,18 @@ Global
78037805
{247E7B6F-FBA2-41A9-BA03-C7C4DF28091C}.Release|x64.Build.0 = Release|Any CPU
78047806
{247E7B6F-FBA2-41A9-BA03-C7C4DF28091C}.Release|x86.ActiveCfg = Release|Any CPU
78057807
{247E7B6F-FBA2-41A9-BA03-C7C4DF28091C}.Release|x86.Build.0 = Release|Any CPU
7808+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
7809+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
7810+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Debug|x64.ActiveCfg = Debug|Any CPU
7811+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Debug|x64.Build.0 = Debug|Any CPU
7812+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Debug|x86.ActiveCfg = Debug|Any CPU
7813+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Debug|x86.Build.0 = Debug|Any CPU
7814+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
7815+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Release|Any CPU.Build.0 = Release|Any CPU
7816+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Release|x64.ActiveCfg = Release|Any CPU
7817+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Release|x64.Build.0 = Release|Any CPU
7818+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Release|x86.ActiveCfg = Release|Any CPU
7819+
{514726D2-3D2E-44C1-B056-163E37DE3E8B}.Release|x86.Build.0 = Release|Any CPU
78067820
EndGlobalSection
78077821
GlobalSection(SolutionProperties) = preSolution
78087822
HideSolutionNode = FALSE
@@ -8613,6 +8627,7 @@ Global
86138627
{F599EAA6-399F-4A91-9B1F-D311305B43D9} = {323C3EB6-1D15-4B3D-918D-699D7F64DED9}
86148628
{17459B97-1AA3-4154-83D3-C6BDC9FA3F85} = {022B4B80-E813-4256-8034-11A68146F4EF}
86158629
{247E7B6F-FBA2-41A9-BA03-C7C4DF28091C} = {B27FBAC2-ADA3-4A05-B232-64011B6B2DA3}
8630+
{514726D2-3D2E-44C1-B056-163E37DE3E8B} = {7B976D8F-EA31-4C0B-97BD-DFD9B3CC86FB}
86168631
EndGlobalSection
86178632
GlobalSection(ExtensibilityGlobals) = postSolution
86188633
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}

src/Servers/Kestrel/Core/src/Internal/Infrastructure/TransportManager.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public async Task<EndPoint> BindAsync(EndPoint endPoint, MultiplexedConnectionDe
6262
// TODO Set other relevant values on options
6363
var sslServerAuthenticationOptions = new SslServerAuthenticationOptions
6464
{
65-
ServerCertificate = listenOptions.HttpsOptions.ServerCertificate
65+
ServerCertificate = listenOptions.HttpsOptions.ServerCertificate,
66+
ApplicationProtocols = new List<SslApplicationProtocol>() { new SslApplicationProtocol("h3") }
6667
};
6768

6869
features.Set(sslServerAuthenticationOptions);

src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs

+30-8
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,36 @@ public async Task StartAsync<TContext>(IHttpApplication<TContext> application, C
160160

161161
async Task OnBind(ListenOptions options, CancellationToken onBindCancellationToken)
162162
{
163+
var hasHttp1 = options.Protocols.HasFlag(HttpProtocols.Http1);
164+
var hasHttp2 = options.Protocols.HasFlag(HttpProtocols.Http2);
165+
var hasHttp3 = options.Protocols.HasFlag(HttpProtocols.Http3);
166+
var hasTls = options.IsTls;
167+
168+
// Filter out invalid combinations.
169+
170+
if (!hasTls)
171+
{
172+
// Http/1 without TLS, no-op HTTP/2 and 3.
173+
if (hasHttp1)
174+
{
175+
hasHttp2 = false;
176+
hasHttp3 = false;
177+
}
178+
// Http/3 requires TLS. Note we only let it fall back to HTTP/1, not HTTP/2
179+
else if (hasHttp3)
180+
{
181+
throw new InvalidOperationException("HTTP/3 requires https.");
182+
}
183+
}
184+
185+
// Quic isn't registered if it's not supported, throw if we can't fall back to 1 or 2
186+
if (hasHttp3 && _multiplexedTransportFactory is null && !(hasHttp1 || hasHttp2))
187+
{
188+
throw new InvalidOperationException("This platform doesn't support QUIC or HTTP/3.");
189+
}
190+
163191
// Add the HTTP middleware as the terminal connection middleware
164-
if ((options.Protocols & HttpProtocols.Http1) == HttpProtocols.Http1
165-
|| (options.Protocols & HttpProtocols.Http2) == HttpProtocols.Http2
192+
if (hasHttp1 || hasHttp2
166193
|| options.Protocols == HttpProtocols.None) // TODO a test fails because it doesn't throw an exception in the right place
167194
// when there is no HttpProtocols in KestrelServer, can we remove/change the test?
168195
{
@@ -180,13 +207,8 @@ async Task OnBind(ListenOptions options, CancellationToken onBindCancellationTok
180207
options.EndPoint = await _transportManager.BindAsync(options.EndPoint, connectionDelegate, options.EndpointConfig, onBindCancellationToken).ConfigureAwait(false);
181208
}
182209

183-
if ((options.Protocols & HttpProtocols.Http3) == HttpProtocols.Http3)
210+
if (hasHttp3 && _multiplexedTransportFactory is not null)
184211
{
185-
if (_multiplexedTransportFactory is null)
186-
{
187-
throw new InvalidOperationException($"Cannot start HTTP/3 server if no {nameof(IMultiplexedConnectionListenerFactory)} is registered.");
188-
}
189-
190212
options.UseHttp3Server(ServiceContext, application, options.Protocols, !options.DisableAltSvcHeader);
191213
var multiplexedConnectionDelegate = ((IMultiplexedConnectionBuilder)options).Build();
192214

src/Servers/Kestrel/Kestrel.slnf

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"solution": {
33
"path": "..\\..\\..\\AspNetCore.sln",
44
"projects": [
5+
"src\\Extensions\\Features\\src\\Microsoft.Extensions.Features.csproj",
6+
"src\\Extensions\\Features\\test\\Microsoft.Extensions.Features.Tests.csproj",
57
"src\\Hosting\\Abstractions\\src\\Microsoft.AspNetCore.Hosting.Abstractions.csproj",
68
"src\\Hosting\\Hosting\\src\\Microsoft.AspNetCore.Hosting.csproj",
79
"src\\Hosting\\Server.Abstractions\\src\\Microsoft.AspNetCore.Hosting.Server.Abstractions.csproj",
8-
"src\\Extensions\\Features\\src\\Microsoft.Extensions.Features.csproj",
9-
"src\\Extensions\\Features\\test\\Microsoft.Extensions.Features.Tests.csproj",
1010
"src\\Http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj",
1111
"src\\Http\\Http.Abstractions\\src\\Microsoft.AspNetCore.Http.Abstractions.csproj",
1212
"src\\Http\\Http.Extensions\\src\\Microsoft.AspNetCore.Http.Extensions.csproj",
@@ -27,6 +27,7 @@
2727
"src\\Servers\\Kestrel\\perf\\Microbenchmarks\\Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks.csproj",
2828
"src\\Servers\\Kestrel\\samples\\Http2SampleApp\\Http2SampleApp.csproj",
2929
"src\\Servers\\Kestrel\\samples\\Http3SampleApp\\Http3SampleApp.csproj",
30+
"src\\Servers\\Kestrel\\samples\\HttpClientApp\\HttpClientApp.csproj",
3031
"src\\Servers\\Kestrel\\samples\\LargeResponseApp\\LargeResponseApp.csproj",
3132
"src\\Servers\\Kestrel\\samples\\PlaintextApp\\PlaintextApp.csproj",
3233
"src\\Servers\\Kestrel\\samples\\SampleApp\\Kestrel.SampleApp.csproj",

src/Servers/Kestrel/Kestrel/src/Microsoft.AspNetCore.Server.Kestrel.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<ItemGroup>
1414
<Reference Include="Microsoft.AspNetCore.Hosting" />
1515
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Core" />
16+
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Quic" />
1617
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" />
1718
</ItemGroup>
1819

src/Servers/Kestrel/Kestrel/src/WebHostBuilderKestrelExtensions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static class WebHostBuilderKestrelExtensions
2929
/// </returns>
3030
public static IWebHostBuilder UseKestrel(this IWebHostBuilder hostBuilder)
3131
{
32+
hostBuilder.UseQuic();
3233
return hostBuilder.ConfigureServices(services =>
3334
{
3435
// Don't override an already-configured transport

src/Servers/Kestrel/Kestrel/test/KestrelConfigurationLoaderTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ public void DefaultConfigSectionCanSetProtocols_MacAndWin7(string input, HttpPro
553553
[InlineData("http1", HttpProtocols.Http1)]
554554
[InlineData("http2", HttpProtocols.Http2)]
555555
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)]
556+
[InlineData("http1AndHttp2andHttp3", HttpProtocols.Http1AndHttp2AndHttp3)]
556557
[OSSkipCondition(OperatingSystems.MacOSX)]
557558
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win81)]
558559
public void DefaultConfigSectionCanSetProtocols_NonMacAndWin7(string input, HttpProtocols expected)

src/Servers/Kestrel/Transport.Quic/src/AssemblyInfo.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66

77
[assembly: InternalsVisibleTo("Quic.FunctionalTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
88
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
9-
[assembly: SupportedOSPlatform("windows")]
10-
[assembly: SupportedOSPlatform("macos")]
11-
[assembly: SupportedOSPlatform("linux")]
9+

src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionListener.cs

-8
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,10 @@ public QuicConnectionListener(QuicTransportOptions options, IQuicTrace log, EndP
3131
throw new NotSupportedException("QUIC is not supported or enabled on this platform. See https://aka.ms/aspnet/kestrel/http3reqs for details.");
3232
}
3333

34-
if (options.Alpn == null)
35-
{
36-
throw new InvalidOperationException("QuicTransportOptions.Alpn must be configured with a value.");
37-
}
38-
3934
_log = log;
4035
_context = new QuicTransportContext(_log, options);
4136
var quicListenerOptions = new QuicListenerOptions();
4237

43-
// TODO Should HTTP/3 specific ALPN still be global? Revisit whether it can be statically set once HTTP/3 is finalized.
44-
sslServerAuthenticationOptions.ApplicationProtocols = new List<SslApplicationProtocol>() { new SslApplicationProtocol(options.Alpn) };
45-
4638
quicListenerOptions.ServerAuthenticationOptions = sslServerAuthenticationOptions;
4739
quicListenerOptions.ListenEndPoint = endpoint as IPEndPoint;
4840
quicListenerOptions.IdleTimeout = options.IdleTimeout;

src/Servers/Kestrel/Transport.Quic/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;kestrel</PackageTags>
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
10-
<NoWarn>CS1591;CS0436;$(NoWarn)</NoWarn><!-- Conflicts between internal and public Quic APIs -->
10+
<NoWarn>CA1416;CS1591;CS0436;$(NoWarn)</NoWarn><!-- Conflicts between internal and public Quic APIs; Platform support warnings. -->
1111
<IsPackable>false</IsPackable>
1212
<Nullable>enable</Nullable>
1313
</PropertyGroup>

src/Servers/Kestrel/Transport.Quic/src/PublicAPI.Unshipped.txt

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
*REMOVED*~static Microsoft.AspNetCore.Hosting.WebHostBuilderMsQuicExtensions.UseQuic(this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder) -> Microsoft.AspNetCore.Hosting.IWebHostBuilder
2727
Microsoft.AspNetCore.Hosting.WebHostBuilderQuicExtensions
2828
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions
29-
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.Alpn.get -> string?
30-
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.Alpn.set -> void
3129
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.IdleTimeout.get -> System.TimeSpan
3230
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.IdleTimeout.set -> void
3331
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxBidirectionalStreamCount.get -> ushort

src/Servers/Kestrel/Transport.Quic/src/QuicConnectionFactory.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,8 @@ public async ValueTask<MultiplexedConnectionContext> ConnectAsync(EndPoint endPo
4040
{
4141
throw new NotSupportedException($"{endPoint} is not supported");
4242
}
43-
if (_transportContext.Options.Alpn == null)
44-
{
45-
throw new InvalidOperationException("QuicTransportOptions.Alpn must be configured with a value.");
46-
}
4743

48-
var sslOptions = new SslClientAuthenticationOptions();
49-
sslOptions.ApplicationProtocols = new List<SslApplicationProtocol>() { new SslApplicationProtocol(_transportContext.Options.Alpn) };
44+
var sslOptions = features?.Get<SslClientAuthenticationOptions>();
5045
var connection = new QuicConnection(QuicImplementationProviders.MsQuic, (IPEndPoint)endPoint, sslOptions);
5146

5247
await connection.ConnectAsync(cancellationToken);

src/Servers/Kestrel/Transport.Quic/src/QuicTransportOptions.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@ public class QuicTransportOptions
2323
/// </summary>
2424
public ushort MaxUnidirectionalStreamCount { get; set; } = 10;
2525

26-
/// <summary>
27-
/// The Application Layer Protocol Negotiation string.
28-
/// </summary>
29-
public string? Alpn { get; set; }
30-
3126
/// <summary>
3227
/// Sets the idle timeout for connections and streams.
3328
/// </summary>
34-
public TimeSpan IdleTimeout { get; set; }
29+
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(130); // Matches KestrelServerLimits.KeepAliveTimeout.
3530

3631
/// <summary>
3732
/// The maximum read size.

src/Servers/Kestrel/Transport.Quic/src/WebHostBuilderQuicExtensions.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ public static class WebHostBuilderQuicExtensions
1616
{
1717
public static IWebHostBuilder UseQuic(this IWebHostBuilder hostBuilder)
1818
{
19-
if (!QuicImplementationProviders.Default.IsSupported)
19+
if (QuicImplementationProviders.Default.IsSupported)
2020
{
21-
throw new NotSupportedException("QUIC is not supported or enabled on this platform. See https://aka.ms/aspnet/kestrel/http3reqs for details.");
21+
return hostBuilder.ConfigureServices(services =>
22+
{
23+
services.AddSingleton<IMultiplexedConnectionListenerFactory, QuicTransportFactory>();
24+
});
2225
}
23-
return hostBuilder.ConfigureServices(services =>
24-
{
25-
services.AddSingleton<IMultiplexedConnectionListenerFactory, QuicTransportFactory>();
26-
});
26+
27+
return hostBuilder;
2728
}
2829

2930
public static IWebHostBuilder UseQuic(this IWebHostBuilder hostBuilder, Action<QuicTransportOptions> configureOptions)

src/Servers/Kestrel/Transport.Quic/test/QuicTestHelpers.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ internal static class QuicTestHelpers
3131
public static QuicTransportFactory CreateTransportFactory(ILoggerFactory loggerFactory = null, ISystemClock systemClock = null)
3232
{
3333
var quicTransportOptions = new QuicTransportOptions();
34-
quicTransportOptions.Alpn = Alpn;
3534
quicTransportOptions.IdleTimeout = TimeSpan.FromMinutes(1);
3635
quicTransportOptions.MaxBidirectionalStreamCount = 200;
3736
quicTransportOptions.MaxUnidirectionalStreamCount = 200;
@@ -59,6 +58,7 @@ public static FeatureCollection CreateBindAsyncFeatures()
5958
var cert = TestResources.GetTestCertificate();
6059

6160
var sslServerAuthenticationOptions = new SslServerAuthenticationOptions();
61+
sslServerAuthenticationOptions.ApplicationProtocols = new List<SslApplicationProtocol>() { new SslApplicationProtocol(Alpn) };
6262
sslServerAuthenticationOptions.ServerCertificate = cert;
6363
sslServerAuthenticationOptions.RemoteCertificateValidationCallback = RemoteCertificateValidationCallback;
6464

src/Servers/Kestrel/Transport.Quic/test/WebHostTests.cs

+5-30
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
using System.Buffers;
64
using System.Net;
75
using System.Net.Http;
8-
using System.Net.Security;
9-
using System.Security.Cryptography.X509Certificates;
10-
using System.Threading;
11-
using System.Threading.Tasks;
126
using Microsoft.AspNetCore.Builder;
137
using Microsoft.AspNetCore.Connections;
148
using Microsoft.AspNetCore.Hosting;
159
using Microsoft.AspNetCore.Http;
16-
using Microsoft.AspNetCore.Http.Features;
1710
using Microsoft.AspNetCore.Server.Kestrel.FunctionalTests;
18-
using Microsoft.AspNetCore.Server.Kestrel.Https;
1911
using Microsoft.AspNetCore.Testing;
2012
using Microsoft.Extensions.Hosting;
21-
using Microsoft.Extensions.Logging.Abstractions;
22-
using Microsoft.Extensions.Options;
2313
using Xunit;
2414

2515
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests
@@ -31,7 +21,7 @@ public class WebHostTests : LoggedTest
3121
public async Task UseUrls_HelloWorld_ClientSuccess()
3222
{
3323
// Arrange
34-
var builder = GetHostBuilder()
24+
var builder = new HostBuilder()
3525
.ConfigureWebHost(webHostBuilder =>
3626
{
3727
webHostBuilder
@@ -82,7 +72,7 @@ public async Task UseUrls_HelloWorld_ClientSuccess()
8272
public async Task Listen_Http3AndSocketsCoexistOnDifferentEndpoints_ClientSuccess(int http3Port, int http1Port)
8373
{
8474
// Arrange
85-
var builder = GetHostBuilder()
75+
var builder = new HostBuilder()
8676
.ConfigureWebHost(webHostBuilder =>
8777
{
8878
webHostBuilder
@@ -122,7 +112,7 @@ public async Task Listen_Http3AndSocketsCoexistOnDifferentEndpoints_ClientSucces
122112
public async Task Listen_Http3AndSocketsCoexistOnSameEndpoint_ClientSuccess()
123113
{
124114
// Arrange
125-
var builder = GetHostBuilder()
115+
var builder = new HostBuilder()
126116
.ConfigureWebHost(webHostBuilder =>
127117
{
128118
webHostBuilder
@@ -157,7 +147,7 @@ public async Task Listen_Http3AndSocketsCoexistOnSameEndpoint_ClientSuccess()
157147
public async Task Listen_Http3AndSocketsCoexistOnSameEndpoint_AltSvcEnabled_Upgrade()
158148
{
159149
// Arrange
160-
var builder = GetHostBuilder()
150+
var builder = new HostBuilder()
161151
.ConfigureWebHost(webHostBuilder =>
162152
{
163153
webHostBuilder
@@ -221,7 +211,7 @@ public async Task Listen_Http3AndSocketsCoexistOnSameEndpoint_AltSvcEnabled_Upgr
221211
public async Task Listen_Http3AndSocketsCoexistOnSameEndpoint_AltSvcDisabled_NoUpgrade()
222212
{
223213
// Arrange
224-
var builder = GetHostBuilder()
214+
var builder = new HostBuilder()
225215
.ConfigureWebHost(webHostBuilder =>
226216
{
227217
webHostBuilder
@@ -321,20 +311,5 @@ private static HttpClient CreateClient()
321311

322312
return new HttpClient(httpHandler);
323313
}
324-
325-
public static IHostBuilder GetHostBuilder(long? maxReadBufferSize = null)
326-
{
327-
return new HostBuilder()
328-
.ConfigureWebHost(webHostBuilder =>
329-
{
330-
webHostBuilder
331-
.UseQuic(options =>
332-
{
333-
options.MaxReadBufferSize = maxReadBufferSize;
334-
options.Alpn = QuicTestHelpers.Alpn;
335-
options.IdleTimeout = TimeSpan.FromSeconds(20);
336-
});
337-
});
338-
}
339314
}
340315
}

0 commit comments

Comments
 (0)