diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 851979376c6d..1c224464df6b 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -9,288 +9,288 @@ --> - + https://github.com/dotnet/efcore - c146f7a38e126f5001cd3383d4b70f250fd6bf3c + b7676717b3c905918251f1eab496fa0032159c21 - + https://github.com/dotnet/efcore - c146f7a38e126f5001cd3383d4b70f250fd6bf3c + b7676717b3c905918251f1eab496fa0032159c21 - + https://github.com/dotnet/efcore - c146f7a38e126f5001cd3383d4b70f250fd6bf3c + b7676717b3c905918251f1eab496fa0032159c21 - + https://github.com/dotnet/efcore - c146f7a38e126f5001cd3383d4b70f250fd6bf3c + b7676717b3c905918251f1eab496fa0032159c21 - + https://github.com/dotnet/efcore - c146f7a38e126f5001cd3383d4b70f250fd6bf3c + b7676717b3c905918251f1eab496fa0032159c21 - + https://github.com/dotnet/efcore - c146f7a38e126f5001cd3383d4b70f250fd6bf3c + b7676717b3c905918251f1eab496fa0032159c21 - + https://github.com/dotnet/efcore - c146f7a38e126f5001cd3383d4b70f250fd6bf3c + b7676717b3c905918251f1eab496fa0032159c21 - + https://github.com/dotnet/efcore - c146f7a38e126f5001cd3383d4b70f250fd6bf3c + b7676717b3c905918251f1eab496fa0032159c21 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 - + https://github.com/dotnet/runtime - 1967649721058a457157d4321af3e6fceaa5441b + b7fca07f478739d9fd50bdf5d1467c02dc05b6b0 https://github.com/dotnet/arcade diff --git a/eng/Versions.props b/eng/Versions.props index 01b4b2b0e004..c93c22b4299a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -65,77 +65,77 @@ --> - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 - 7.0.0-preview.7.22358.7 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 + 7.0.0-preview.7.22362.12 - 7.0.0-preview.7.22358.7 + 7.0.0-preview.7.22362.12 - 7.0.0-preview.7.22361.4 - 7.0.0-preview.7.22361.4 - 7.0.0-preview.7.22361.4 - 7.0.0-preview.7.22361.4 - 7.0.0-preview.7.22361.4 - 7.0.0-preview.7.22361.4 - 7.0.0-preview.7.22361.4 - 7.0.0-preview.7.22361.4 + 7.0.0-rc.1.22363.4 + 7.0.0-rc.1.22363.4 + 7.0.0-rc.1.22363.4 + 7.0.0-rc.1.22363.4 + 7.0.0-rc.1.22363.4 + 7.0.0-rc.1.22363.4 + 7.0.0-rc.1.22363.4 + 7.0.0-rc.1.22363.4 7.0.0-beta.22358.3 7.0.0-beta.22358.3 diff --git a/src/Middleware/ConcurrencyLimiter/src/QueuePolicies/BasePolicy.cs b/src/Middleware/ConcurrencyLimiter/src/QueuePolicies/BasePolicy.cs index d9a6cbffc526..6ef1f4390795 100644 --- a/src/Middleware/ConcurrencyLimiter/src/QueuePolicies/BasePolicy.cs +++ b/src/Middleware/ConcurrencyLimiter/src/QueuePolicies/BasePolicy.cs @@ -47,7 +47,7 @@ public ValueTask TryEnterAsync() return ValueTask.FromResult(true); } - var task = _limiter.WaitAsync(); + var task = _limiter.WaitAndAcquireAsync(); if (task.IsCompletedSuccessfully) { lease = task.Result; diff --git a/src/Middleware/RateLimiting/samples/RateLimitingSample/Program.cs b/src/Middleware/RateLimiting/samples/RateLimitingSample/Program.cs index 0a13c89566ac..b43728b1baf4 100644 --- a/src/Middleware/RateLimiting/samples/RateLimitingSample/Program.cs +++ b/src/Middleware/RateLimiting/samples/RateLimitingSample/Program.cs @@ -30,7 +30,7 @@ // The global limiter will be a concurrency limiter with a max permit count of 10 and a queue depth of 5. options.GlobalLimiter = PartitionedRateLimiter.Create(context => { - return RateLimitPartition.CreateConcurrencyLimiter("globalLimiter", key => new ConcurrencyLimiterOptions(10, QueueProcessingOrder.NewestFirst, 5)); + return RateLimitPartition.GetConcurrencyLimiter("globalLimiter", key => new ConcurrencyLimiterOptions(10, QueueProcessingOrder.NewestFirst, 5)); }); app.UseRateLimiter(options); diff --git a/src/Middleware/RateLimiting/samples/RateLimitingSample/SampleRateLimiterPolicy.cs b/src/Middleware/RateLimiting/samples/RateLimitingSample/SampleRateLimiterPolicy.cs index fc04c71a5202..8844e1d65446 100644 --- a/src/Middleware/RateLimiting/samples/RateLimitingSample/SampleRateLimiterPolicy.cs +++ b/src/Middleware/RateLimiting/samples/RateLimitingSample/SampleRateLimiterPolicy.cs @@ -25,6 +25,6 @@ public SampleRateLimiterPolicy(ILogger logger) // Use a sliding window limiter allowing 1 request every 10 seconds public RateLimitPartition GetPartition(HttpContext httpContext) { - return RateLimitPartition.CreateSlidingWindowLimiter(string.Empty, key => new SlidingWindowRateLimiterOptions(1, QueueProcessingOrder.OldestFirst, 1, TimeSpan.FromSeconds(5), 1)); + return RateLimitPartition.GetSlidingWindowLimiter(string.Empty, key => new SlidingWindowRateLimiterOptions(1, QueueProcessingOrder.OldestFirst, 1, TimeSpan.FromSeconds(5), 1)); } } diff --git a/src/Middleware/RateLimiting/src/RateLimiterOptionsExtensions.cs b/src/Middleware/RateLimiting/src/RateLimiterOptionsExtensions.cs index e7067ef5da5c..2a6f40dc7058 100644 --- a/src/Middleware/RateLimiting/src/RateLimiterOptionsExtensions.cs +++ b/src/Middleware/RateLimiting/src/RateLimiterOptionsExtensions.cs @@ -22,7 +22,7 @@ public static RateLimiterOptions AddTokenBucketLimiter(this RateLimiterOptions o var key = new PolicyNameKey() { PolicyName = policyName }; return options.AddPolicy(policyName, context => { - return RateLimitPartition.CreateTokenBucketLimiter(key, + return RateLimitPartition.GetTokenBucketLimiter(key, _ => tokenBucketRateLimiterOptions); }); } @@ -39,7 +39,7 @@ public static RateLimiterOptions AddFixedWindowLimiter(this RateLimiterOptions o var key = new PolicyNameKey() { PolicyName = policyName }; return options.AddPolicy(policyName, context => { - return RateLimitPartition.CreateFixedWindowLimiter(key, + return RateLimitPartition.GetFixedWindowLimiter(key, _ => fixedWindowRateLimiterOptions); }); } @@ -56,7 +56,7 @@ public static RateLimiterOptions AddSlidingWindowLimiter(this RateLimiterOptions var key = new PolicyNameKey() { PolicyName = policyName }; return options.AddPolicy(policyName, context => { - return RateLimitPartition.CreateSlidingWindowLimiter(key, + return RateLimitPartition.GetSlidingWindowLimiter(key, _ => slidingWindowRateLimiterOptions); }); } @@ -73,7 +73,7 @@ public static RateLimiterOptions AddConcurrencyLimiter(this RateLimiterOptions o var key = new PolicyNameKey() { PolicyName = policyName }; return options.AddPolicy(policyName, context => { - return RateLimitPartition.CreateConcurrencyLimiter(key, + return RateLimitPartition.GetConcurrencyLimiter(key, _ => concurrencyLimiterOptions); }); } @@ -89,7 +89,7 @@ public static RateLimiterOptions AddNoLimiter(this RateLimiterOptions options, s var key = new PolicyNameKey() { PolicyName = policyName }; return options.AddPolicy(policyName, context => { - return RateLimitPartition.CreateNoLimiter(key); + return RateLimitPartition.GetNoLimiter(key); }); } } diff --git a/src/Middleware/RateLimiting/src/RateLimitingMiddleware.cs b/src/Middleware/RateLimiting/src/RateLimitingMiddleware.cs index d352e3546dde..0ffa8e1d485d 100644 --- a/src/Middleware/RateLimiting/src/RateLimitingMiddleware.cs +++ b/src/Middleware/RateLimiting/src/RateLimitingMiddleware.cs @@ -142,13 +142,13 @@ private async ValueTask CombinedWaitAsync(HttpContext context, Can { if (_globalLimiter is not null) { - globalLease = await _globalLimiter.WaitAsync(context, cancellationToken: cancellationToken); + globalLease = await _globalLimiter.WaitAndAcquireAsync(context, cancellationToken: cancellationToken); if (!globalLease.IsAcquired) { return new LeaseContext() { GlobalRejected = true, Lease = globalLease }; } } - endpointLease = await _endpointLimiter.WaitAsync(context, cancellationToken: cancellationToken); + endpointLease = await _endpointLimiter.WaitAndAcquireAsync(context, cancellationToken: cancellationToken); if (!endpointLease.IsAcquired) { globalLease?.Dispose(); @@ -183,7 +183,7 @@ private PartitionedRateLimiter CreateEndpointLimiter() throw new InvalidOperationException($"This endpoint requires a rate limiting policy with name {name}, but no such policy exists."); } } - return RateLimitPartition.CreateNoLimiter(_defaultPolicyKey); + return RateLimitPartition.GetNoLimiter(_defaultPolicyKey); }, new DefaultKeyTypeEqualityComparer()); } diff --git a/src/Middleware/RateLimiting/test/RateLimitingMiddlewareTests.cs b/src/Middleware/RateLimiting/test/RateLimitingMiddlewareTests.cs index 91b0697c5f4a..ff090f2f57d1 100644 --- a/src/Middleware/RateLimiting/test/RateLimitingMiddlewareTests.cs +++ b/src/Middleware/RateLimiting/test/RateLimitingMiddlewareTests.cs @@ -160,7 +160,7 @@ public async Task EndpointLimiter_Rejects() var name = "myEndpoint"; options.Value.AddPolicy(name, (context => { - return RateLimitPartition.Create("myLimiter", (key => + return RateLimitPartition.Get("myLimiter", (key => { return new TestRateLimiter(false); })); diff --git a/src/Middleware/RateLimiting/test/RateLimitingOptionsTests.cs b/src/Middleware/RateLimiting/test/RateLimitingOptionsTests.cs index a58512e28f99..a1647ed6cf46 100644 --- a/src/Middleware/RateLimiting/test/RateLimitingOptionsTests.cs +++ b/src/Middleware/RateLimiting/test/RateLimitingOptionsTests.cs @@ -13,7 +13,7 @@ public class RateLimitingOptionsTests public void AddPolicy_ThrowsOnNullPolicyName() { var options = new RateLimiterOptions(); - Assert.Throws(() => options.AddPolicy(null, context => RateLimitPartition.CreateNoLimiter("myKey"))); + Assert.Throws(() => options.AddPolicy(null, context => RateLimitPartition.GetNoLimiter("myKey"))); } [Fact] @@ -34,15 +34,15 @@ public void AddPolicy_ThrowsOnNullPolicy() public void AddPolicy_ThrowsOnDuplicateName() { var options = new RateLimiterOptions(); - options.AddPolicy("myKey", context => RateLimitPartition.CreateNoLimiter("myKey")); - Assert.Throws(() => options.AddPolicy("myKey", context => RateLimitPartition.CreateNoLimiter("yourKey"))); + options.AddPolicy("myKey", context => RateLimitPartition.GetNoLimiter("myKey")); + Assert.Throws(() => options.AddPolicy("myKey", context => RateLimitPartition.GetNoLimiter("yourKey"))); } [Fact] public void AddPolicy_Generic_ThrowsOnDuplicateName() { var options = new RateLimiterOptions(); - options.AddPolicy("myKey", context => RateLimitPartition.CreateNoLimiter("myKey")); + options.AddPolicy("myKey", context => RateLimitPartition.GetNoLimiter("myKey")); Assert.Throws(() => options.AddPolicy("myKey")); } } diff --git a/src/Middleware/RateLimiting/test/TestPartitionedRateLimiter.cs b/src/Middleware/RateLimiting/test/TestPartitionedRateLimiter.cs index 12e21ffbc518..90a778aaeae2 100644 --- a/src/Middleware/RateLimiting/test/TestPartitionedRateLimiter.cs +++ b/src/Middleware/RateLimiting/test/TestPartitionedRateLimiter.cs @@ -57,7 +57,7 @@ protected override RateLimitLease AcquireCore(TResource resourceID, int permitCo return new TestRateLimitLease(true, leases); } - protected override async ValueTask WaitAsyncCore(TResource resourceID, int permitCount, CancellationToken cancellationToken) + protected override async ValueTask WaitAndAcquireAsyncCore(TResource resourceID, int permitCount, CancellationToken cancellationToken) { if (permitCount != 1) { @@ -66,7 +66,7 @@ protected override async ValueTask WaitAsyncCore(TResource resou var leases = new List(); foreach (var limiter in limiters) { - leases.Add(await limiter.WaitAsync()); + leases.Add(await limiter.WaitAndAcquireAsync()); } foreach (var lease in leases) { diff --git a/src/Middleware/RateLimiting/test/TestRateLimiter.cs b/src/Middleware/RateLimiting/test/TestRateLimiter.cs index 037b2fa5250b..f0acba0cc777 100644 --- a/src/Middleware/RateLimiting/test/TestRateLimiter.cs +++ b/src/Middleware/RateLimiting/test/TestRateLimiter.cs @@ -4,6 +4,7 @@ using System.Threading.RateLimiting; namespace Microsoft.AspNetCore.RateLimiting; + internal class TestRateLimiter : RateLimiter { private readonly bool _alwaysAccept; @@ -25,7 +26,7 @@ protected override RateLimitLease AcquireCore(int permitCount) return new TestRateLimitLease(_alwaysAccept, null); } - protected override ValueTask WaitAsyncCore(int permitCount, CancellationToken cancellationToken) + protected override ValueTask WaitAndAcquireAsyncCore(int permitCount, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return new ValueTask(new TestRateLimitLease(_alwaysAccept, null)); diff --git a/src/Middleware/RateLimiting/test/TestRateLimiterPolicy.cs b/src/Middleware/RateLimiting/test/TestRateLimiterPolicy.cs index 777935a092f3..49a7cd7845a7 100644 --- a/src/Middleware/RateLimiting/test/TestRateLimiterPolicy.cs +++ b/src/Middleware/RateLimiting/test/TestRateLimiterPolicy.cs @@ -27,7 +27,7 @@ public TestRateLimiterPolicy(string key, int statusCode, bool alwaysAccept) public RateLimitPartition GetPartition(HttpContext httpContext) { - return RateLimitPartition.Create(_key, (key => + return RateLimitPartition.Get(_key, (key => { return new TestRateLimiter(_alwaysAccept); })); diff --git a/src/Servers/HttpSys/test/FunctionalTests/Http3Tests.cs b/src/Servers/HttpSys/test/FunctionalTests/Http3Tests.cs index 569b06045c75..e97a59ecdc72 100644 --- a/src/Servers/HttpSys/test/FunctionalTests/Http3Tests.cs +++ b/src/Servers/HttpSys/test/FunctionalTests/Http3Tests.cs @@ -174,8 +174,9 @@ public async Task Http3_ResetBeforeHeaders() client.DefaultRequestVersion = HttpVersion.Version30; client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; var ex = await Assert.ThrowsAsync(() => client.GetAsync(address)); - var qex = Assert.IsType(ex.InnerException); - Assert.Equal(0x010b, qex.ErrorCode); + var qex = Assert.IsType(ex.InnerException); + Assert.Equal(QuicError.StreamAborted, qex.QuicError); + Assert.Equal(0x010b, qex.ApplicationErrorCode.Value); } [ConditionalFact] @@ -206,8 +207,9 @@ public async Task Http3_ResetAfterHeaders() headersReceived.SetResult(); response.EnsureSuccessStatusCode(); var ex = await Assert.ThrowsAsync(() => response.Content.ReadAsStringAsync()); - var qex = Assert.IsType(ex.InnerException?.InnerException?.InnerException); - Assert.Equal(0x010c, qex.ErrorCode); + var qex = Assert.IsType(ex.InnerException?.InnerException?.InnerException); + Assert.Equal(QuicError.StreamAborted, qex.QuicError); + Assert.Equal(0x010c, qex.ApplicationErrorCode.Value); } [ConditionalFact] @@ -231,8 +233,9 @@ public async Task Http3_AppExceptionAfterHeaders_InternalError() headersReceived.SetResult(); response.EnsureSuccessStatusCode(); var ex = await Assert.ThrowsAsync(() => response.Content.ReadAsStringAsync()); - var qex = Assert.IsType(ex.InnerException?.InnerException?.InnerException); - Assert.Equal(0x0102, qex.ErrorCode); // H3_INTERNAL_ERROR + var qex = Assert.IsType(ex.InnerException?.InnerException?.InnerException); + Assert.Equal(QuicError.StreamAborted, qex.QuicError); + Assert.Equal(0x0102, qex.ApplicationErrorCode.Value); // H3_INTERNAL_ERROR } [ConditionalFact] @@ -251,7 +254,8 @@ public async Task Http3_Abort_Cancel() client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; var ex = await Assert.ThrowsAsync(() => client.GetAsync(address)); - var qex = Assert.IsType(ex.InnerException); - Assert.Equal(0x010c, qex.ErrorCode); // H3_REQUEST_CANCELLED + var qex = Assert.IsType(ex.InnerException); + Assert.Equal(QuicError.StreamAborted, qex.QuicError); + Assert.Equal(0x010c, qex.ApplicationErrorCode.Value); // H3_REQUEST_CANCELLED } } diff --git a/src/Servers/HttpSys/test/FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj b/src/Servers/HttpSys/test/FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj index 6521a8b8f52a..84b25cd49b3c 100644 --- a/src/Servers/HttpSys/test/FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj +++ b/src/Servers/HttpSys/test/FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj @@ -4,6 +4,8 @@ $(DefaultNetCoreTargetFramework) HttpSys.FunctionalTests true + + true diff --git a/src/Servers/IIS/IIS/test/IIS.FunctionalTests/Http3Tests.cs b/src/Servers/IIS/IIS/test/IIS.FunctionalTests/Http3Tests.cs index be5022389b1e..3ee6212c4623 100644 --- a/src/Servers/IIS/IIS/test/IIS.FunctionalTests/Http3Tests.cs +++ b/src/Servers/IIS/IIS/test/IIS.FunctionalTests/Http3Tests.cs @@ -120,8 +120,9 @@ public async Task Http3_ResetBeforeHeaders() client.DefaultRequestVersion = HttpVersion.Version30; client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; var ex = await Assert.ThrowsAsync(() => client.GetAsync(address)); - var qex = Assert.IsType(ex.InnerException); - Assert.Equal(0x010b, qex.ErrorCode); + var qex = Assert.IsType(ex.InnerException); + Assert.Equal(QuicError.StreamAborted, qex.QuicError); + Assert.Equal(0x010b, qex.ApplicationErrorCode.Value); } [ConditionalFact] @@ -135,8 +136,9 @@ public async Task Http3_ResetAfterHeaders() await client.GetAsync(Fixture.Client.BaseAddress.ToString() + "Http3_ResetAfterHeaders_SetResult"); response.EnsureSuccessStatusCode(); var ex = await Assert.ThrowsAsync(() => response.Content.ReadAsStringAsync()); - var qex = Assert.IsType(ex.InnerException?.InnerException?.InnerException); - Assert.Equal(0x010c, qex.ErrorCode); // H3_REQUEST_CANCELLED + var qex = Assert.IsType(ex.InnerException?.InnerException?.InnerException); + Assert.Equal(QuicError.StreamAborted, qex.QuicError); + Assert.Equal(0x010c, qex.ApplicationErrorCode.Value); // H3_REQUEST_CANCELLED } [ConditionalFact] @@ -151,8 +153,9 @@ public async Task Http3_AppExceptionAfterHeaders_InternalError() await client.GetAsync(Fixture.Client.BaseAddress.ToString() + "Http3_AppExceptionAfterHeaders_InternalError_SetResult"); response.EnsureSuccessStatusCode(); var ex = await Assert.ThrowsAsync(() => response.Content.ReadAsStringAsync()); - var qex = Assert.IsType(ex.InnerException?.InnerException?.InnerException); - Assert.Equal(0x0102, qex.ErrorCode); // H3_INTERNAL_ERROR + var qex = Assert.IsType(ex.InnerException?.InnerException?.InnerException); + Assert.Equal(QuicError.StreamAborted, qex.QuicError); + Assert.Equal(0x0102, qex.ApplicationErrorCode.Value); // H3_INTERNAL_ERROR } [ConditionalFact] @@ -164,8 +167,9 @@ public async Task Http3_Abort_Cancel() client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; var ex = await Assert.ThrowsAsync(() => client.GetAsync(address)); - var qex = Assert.IsType(ex.InnerException); - Assert.Equal(0x010c, qex.ErrorCode); // H3_REQUEST_CANCELLED + var qex = Assert.IsType(ex.InnerException); + Assert.Equal(QuicError.StreamAborted, qex.QuicError); + Assert.Equal(0x010c, qex.ApplicationErrorCode.Value); // H3_REQUEST_CANCELLED } private HttpClient SetUpClient() diff --git a/src/Servers/IIS/IIS/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj b/src/Servers/IIS/IIS/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj index 15848aa053a5..0265c003a849 100644 --- a/src/Servers/IIS/IIS/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj +++ b/src/Servers/IIS/IIS/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj @@ -1,4 +1,4 @@ - + $(DefaultNetCoreTargetFramework) @@ -7,6 +7,8 @@ True true true + + true diff --git a/src/Servers/Kestrel/Core/src/Internal/SniOptionsSelector.cs b/src/Servers/Kestrel/Core/src/Internal/SniOptionsSelector.cs index efbae1ddd250..6f1318ef7bfb 100644 --- a/src/Servers/Kestrel/Core/src/Internal/SniOptionsSelector.cs +++ b/src/Servers/Kestrel/Core/src/Internal/SniOptionsSelector.cs @@ -194,6 +194,7 @@ internal static SslServerAuthenticationOptions CloneSslOptions(SslServerAuthenti ServerCertificate = sslOptions.ServerCertificate, ServerCertificateContext = sslOptions.ServerCertificateContext, ServerCertificateSelectionCallback = sslOptions.ServerCertificateSelectionCallback, + CertificateChainPolicy = sslOptions.CertificateChainPolicy, }; private sealed class SniOptions diff --git a/src/Servers/Kestrel/Core/test/SniOptionsSelectorTests.cs b/src/Servers/Kestrel/Core/test/SniOptionsSelectorTests.cs index 714e522aa7c1..0e1eab5e563e 100644 --- a/src/Servers/Kestrel/Core/test/SniOptionsSelectorTests.cs +++ b/src/Servers/Kestrel/Core/test/SniOptionsSelectorTests.cs @@ -794,6 +794,8 @@ public void CloneSslOptionsClonesAllProperties() ServerCertificateContext = SslStreamCertificateContext.Create(_x509Certificate2, additionalCertificates: null, offline: true), // Defaults to null ServerCertificateSelectionCallback = (sender, serverName) => null, + // Defaults to null + CertificateChainPolicy = new X509ChainPolicy(), }; var clonedOptions = SniOptionsSelector.CloneSslOptions(options); @@ -836,6 +838,9 @@ public void CloneSslOptionsClonesAllProperties() Assert.Same(options.ServerCertificateSelectionCallback, clonedOptions.ServerCertificateSelectionCallback); Assert.True(propertyNames.Remove(nameof(options.ServerCertificateSelectionCallback))); + Assert.Same(options.CertificateChainPolicy, clonedOptions.CertificateChainPolicy); + Assert.True(propertyNames.Remove(nameof(options.CertificateChainPolicy))); + // Ensure we've checked every property. When new properties get added, we'll have to update this test along with the CloneSslOptions implementation. Assert.Empty(propertyNames); } diff --git a/src/Servers/Kestrel/Kestrel.slnf b/src/Servers/Kestrel/Kestrel.slnf index db0f9a4af543..2d90eb4baf0e 100644 --- a/src/Servers/Kestrel/Kestrel.slnf +++ b/src/Servers/Kestrel/Kestrel.slnf @@ -2,17 +2,11 @@ "solution": { "path": "..\\..\\..\\AspNetCore.sln", "projects": [ - "src\\DataProtection\\Abstractions\\src\\Microsoft.AspNetCore.DataProtection.Abstractions.csproj", - "src\\DataProtection\\Cryptography.Internal\\src\\Microsoft.AspNetCore.Cryptography.Internal.csproj", - "src\\DataProtection\\DataProtection\\src\\Microsoft.AspNetCore.DataProtection.csproj", - "src\\DefaultBuilder\\src\\Microsoft.AspNetCore.csproj", "src\\Extensions\\Features\\src\\Microsoft.Extensions.Features.csproj", "src\\Extensions\\Features\\test\\Microsoft.Extensions.Features.Tests.csproj", "src\\Hosting\\Abstractions\\src\\Microsoft.AspNetCore.Hosting.Abstractions.csproj", "src\\Hosting\\Hosting\\src\\Microsoft.AspNetCore.Hosting.csproj", "src\\Hosting\\Server.Abstractions\\src\\Microsoft.AspNetCore.Hosting.Server.Abstractions.csproj", - "src\\Http\\Authentication.Abstractions\\src\\Microsoft.AspNetCore.Authentication.Abstractions.csproj", - "src\\Http\\Authentication.Core\\src\\Microsoft.AspNetCore.Authentication.Core.csproj", "src\\Http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj", "src\\Http\\Http.Abstractions\\src\\Microsoft.AspNetCore.Http.Abstractions.csproj", "src\\Http\\Http.Extensions\\src\\Microsoft.AspNetCore.Http.Extensions.csproj", @@ -27,13 +21,8 @@ "src\\Middleware\\HostFiltering\\src\\Microsoft.AspNetCore.HostFiltering.csproj", "src\\Middleware\\HttpOverrides\\src\\Microsoft.AspNetCore.HttpOverrides.csproj", "src\\ObjectPool\\src\\Microsoft.Extensions.ObjectPool.csproj", - "src\\Security\\Authentication\\Core\\src\\Microsoft.AspNetCore.Authentication.csproj", "src\\Security\\Authorization\\Core\\src\\Microsoft.AspNetCore.Authorization.csproj", - "src\\Security\\Authorization\\Policy\\src\\Microsoft.AspNetCore.Authorization.Policy.csproj", "src\\Servers\\Connections.Abstractions\\src\\Microsoft.AspNetCore.Connections.Abstractions.csproj", - "src\\Servers\\HttpSys\\src\\Microsoft.AspNetCore.Server.HttpSys.csproj", - "src\\Servers\\IIS\\IISIntegration\\src\\Microsoft.AspNetCore.Server.IISIntegration.csproj", - "src\\Servers\\IIS\\IIS\\src\\Microsoft.AspNetCore.Server.IIS.csproj", "src\\Servers\\Kestrel\\Core\\src\\Microsoft.AspNetCore.Server.Kestrel.Core.csproj", "src\\Servers\\Kestrel\\Core\\test\\Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj", "src\\Servers\\Kestrel\\Kestrel\\src\\Microsoft.AspNetCore.Server.Kestrel.csproj", @@ -56,8 +45,7 @@ "src\\Servers\\Kestrel\\test\\Sockets.BindTests\\Sockets.BindTests.csproj", "src\\Servers\\Kestrel\\test\\Sockets.FunctionalTests\\Sockets.FunctionalTests.csproj", "src\\Servers\\Kestrel\\tools\\CodeGenerator\\CodeGenerator.csproj", - "src\\Testing\\src\\Microsoft.AspNetCore.Testing.csproj", - "src\\WebEncoders\\src\\Microsoft.Extensions.WebEncoders.csproj" + "src\\Testing\\src\\Microsoft.AspNetCore.Testing.csproj" ] } } \ No newline at end of file diff --git a/src/Servers/Kestrel/Kestrel/src/WebHostBuilderKestrelExtensions.cs b/src/Servers/Kestrel/Kestrel/src/WebHostBuilderKestrelExtensions.cs index 7ddc532a7f2d..3cc71543c66d 100644 --- a/src/Servers/Kestrel/Kestrel/src/WebHostBuilderKestrelExtensions.cs +++ b/src/Servers/Kestrel/Kestrel/src/WebHostBuilderKestrelExtensions.cs @@ -29,6 +29,7 @@ public static class WebHostBuilderKestrelExtensions public static IWebHostBuilder UseKestrel(this IWebHostBuilder hostBuilder) { hostBuilder.UseQuic(); + return hostBuilder.ConfigureServices(services => { // Don't override an already-configured transport diff --git a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.cs b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.cs index f3cbb0daaa6d..5f9828d868f6 100644 --- a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.cs +++ b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.cs @@ -122,11 +122,11 @@ public override void Abort(ConnectionAbortedException abortReason) return context; } - catch (QuicConnectionAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted) { // Shutdown initiated by peer, abortive. - _error = ex.ErrorCode; - QuicLog.ConnectionAborted(_log, this, ex.ErrorCode, ex); + _error = ex.ApplicationErrorCode; + QuicLog.ConnectionAborted(_log, this, ex.ApplicationErrorCode.GetValueOrDefault(), ex); ThreadPool.UnsafeQueueUserWorkItem(state => { @@ -138,7 +138,7 @@ public override void Abort(ConnectionAbortedException abortReason) // Throw error so consumer sees the connection is aborted by peer. throw new ConnectionResetException(ex.Message, ex); } - catch (QuicOperationAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.OperationAborted) { lock (_shutdownLock) { diff --git a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionListener.cs b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionListener.cs index 15e8b02af304..0f6c16a5e31a 100644 --- a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionListener.cs +++ b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionListener.cs @@ -28,21 +28,35 @@ public QuicConnectionListener(QuicTransportOptions options, ILogger log, EndPoin throw new NotSupportedException("QUIC is not supported or enabled on this platform. See https://aka.ms/aspnet/kestrel/http3reqs for details."); } - _log = log; - _context = new QuicTransportContext(_log, options); - _quicListenerOptions = new(); - if (endpoint is not IPEndPoint listenEndPoint) { throw new InvalidOperationException($"QUIC doesn't support listening on the configured endpoint type. Expected {nameof(IPEndPoint)} but got {endpoint.GetType().Name}."); } - _quicListenerOptions.ServerAuthenticationOptions = sslServerAuthenticationOptions; - _quicListenerOptions.ListenEndPoint = listenEndPoint; - _quicListenerOptions.IdleTimeout = options.IdleTimeout; - _quicListenerOptions.MaxBidirectionalStreams = options.MaxBidirectionalStreamCount; - _quicListenerOptions.MaxUnidirectionalStreams = options.MaxUnidirectionalStreamCount; - _quicListenerOptions.ListenBacklog = options.Backlog; + if (sslServerAuthenticationOptions.ApplicationProtocols is null || sslServerAuthenticationOptions.ApplicationProtocols.Count == 0) + { + throw new InvalidOperationException("No application protocols specified."); + } + + _log = log; + _context = new QuicTransportContext(_log, options); + _quicListenerOptions = new QuicListenerOptions + { + ApplicationProtocols = sslServerAuthenticationOptions.ApplicationProtocols, + ListenEndPoint = listenEndPoint, + ListenBacklog = options.Backlog, + ConnectionOptionsCallback = (connection, helloInfo, cancellationToken) => + { + var connectionOptions = new QuicServerConnectionOptions + { + ServerAuthenticationOptions = sslServerAuthenticationOptions, + IdleTimeout = options.IdleTimeout, + MaxBidirectionalStreams = options.MaxBidirectionalStreamCount, + MaxUnidirectionalStreams = options.MaxUnidirectionalStreamCount + }; + return ValueTask.FromResult(connectionOptions); + } + }; // Setting to listenEndPoint to prevent the property from being null. // This will be initialized when CreateListenerAsync() is invoked. @@ -56,7 +70,7 @@ public async ValueTask CreateListenerAsync() _listener = await QuicListener.ListenAsync(_quicListenerOptions); // Listener endpoint will resolve an ephemeral port, e.g. 127.0.0.1:0, into the actual port. - EndPoint = _listener.ListenEndPoint; + EndPoint = _listener.LocalEndPoint; } public async ValueTask AcceptAsync(IFeatureCollection? features = null, CancellationToken cancellationToken = default) @@ -75,7 +89,7 @@ public async ValueTask CreateListenerAsync() return connectionContext; } - catch (QuicOperationAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.OperationAborted) { _log.LogDebug("Listener has aborted with exception: {Message}", ex.Message); } @@ -87,16 +101,17 @@ public async ValueTask UnbindAsync(CancellationToken cancellationToken = default await DisposeAsync(); } - public ValueTask DisposeAsync() + public async ValueTask DisposeAsync() { if (_disposed) { - return ValueTask.CompletedTask; + return; } - _listener?.Dispose(); + if (_listener != null) + { + await _listener.DisposeAsync(); + } _disposed = true; - - return ValueTask.CompletedTask; } } diff --git a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.cs b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.cs index ec2b41075226..8e27ecdcef95 100644 --- a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.cs +++ b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.cs @@ -258,29 +258,29 @@ private async Task DoReceive() } } } - catch (QuicStreamAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.StreamAborted) { // Abort from peer. - _error = ex.ErrorCode; - QuicLog.StreamAbortedRead(_log, this, ex.ErrorCode); + _error = ex.ApplicationErrorCode; + QuicLog.StreamAbortedRead(_log, this, ex.ApplicationErrorCode.GetValueOrDefault()); // This could be ignored if _shutdownReason is already set. error = new ConnectionResetException(ex.Message, ex); _clientAbort = true; } - catch (QuicConnectionAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted) { // Abort from peer. - _error = ex.ErrorCode; - QuicLog.StreamAbortedRead(_log, this, ex.ErrorCode); + _error = ex.ApplicationErrorCode; + QuicLog.StreamAbortedRead(_log, this, ex.ApplicationErrorCode.GetValueOrDefault()); // This could be ignored if _shutdownReason is already set. error = new ConnectionResetException(ex.Message, ex); _clientAbort = true; } - catch (QuicOperationAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.OperationAborted) { // AbortRead has been called for the stream. error = new ConnectionAbortedException(ex.Message, ex); @@ -409,29 +409,29 @@ private async Task DoSend() } } } - catch (QuicStreamAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.StreamAborted) { // Abort from peer. - _error = ex.ErrorCode; - QuicLog.StreamAbortedWrite(_log, this, ex.ErrorCode); + _error = ex.ApplicationErrorCode; + QuicLog.StreamAbortedWrite(_log, this, ex.ApplicationErrorCode.GetValueOrDefault()); // This could be ignored if _shutdownReason is already set. shutdownReason = new ConnectionResetException(ex.Message, ex); _clientAbort = true; } - catch (QuicConnectionAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted) { // Abort from peer. - _error = ex.ErrorCode; - QuicLog.StreamAbortedWrite(_log, this, ex.ErrorCode); + _error = ex.ApplicationErrorCode; + QuicLog.StreamAbortedWrite(_log, this, ex.ApplicationErrorCode.GetValueOrDefault()); // This could be ignored if _shutdownReason is already set. shutdownReason = new ConnectionResetException(ex.Message, ex); _clientAbort = true; } - catch (QuicOperationAbortedException ex) + catch (QuicException ex) when (ex.QuicError == QuicError.OperationAborted) { // AbortWrite has been called for the stream. // Possibily might also get here from connection closing. diff --git a/src/Servers/Kestrel/Transport.Quic/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.csproj b/src/Servers/Kestrel/Transport.Quic/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.csproj index ed2ea00b91d9..59ffd5596c92 100644 --- a/src/Servers/Kestrel/Transport.Quic/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.csproj +++ b/src/Servers/Kestrel/Transport.Quic/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.csproj @@ -7,8 +7,7 @@ true aspnetcore;kestrel true - CA1416;CS0436;$(NoWarn) - $(NoWarn);IDE0060 + $(NoWarn);CA2252;CA1416 false true diff --git a/src/Servers/Kestrel/Transport.Quic/src/QuicConnectionFactory.cs b/src/Servers/Kestrel/Transport.Quic/src/QuicConnectionFactory.cs index d097e73e8139..0ddec2fe7484 100644 --- a/src/Servers/Kestrel/Transport.Quic/src/QuicConnectionFactory.cs +++ b/src/Servers/Kestrel/Transport.Quic/src/QuicConnectionFactory.cs @@ -40,7 +40,7 @@ public async ValueTask ConnectAsync(EndPoint endPo var connection = await QuicConnection.ConnectAsync(new QuicClientConnectionOptions() { RemoteEndPoint = endPoint, - ClientAuthenticationOptions = sslOptions + ClientAuthenticationOptions = sslOptions ?? new SslClientAuthenticationOptions() }, cancellationToken); await connection.ConnectAsync(cancellationToken); diff --git a/src/Servers/Kestrel/Transport.Quic/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.csproj b/src/Servers/Kestrel/Transport.Quic/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.csproj index 8a954dc2caa9..42ecb12eb271 100644 --- a/src/Servers/Kestrel/Transport.Quic/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.csproj +++ b/src/Servers/Kestrel/Transport.Quic/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.csproj @@ -4,6 +4,8 @@ $(DefaultNetCoreTargetFramework) true true + + true diff --git a/src/Servers/Kestrel/Transport.Quic/test/QuicConnectionContextTests.cs b/src/Servers/Kestrel/Transport.Quic/test/QuicConnectionContextTests.cs index a04a4eb9d797..e09068ffe317 100644 --- a/src/Servers/Kestrel/Transport.Quic/test/QuicConnectionContextTests.cs +++ b/src/Servers/Kestrel/Transport.Quic/test/QuicConnectionContextTests.cs @@ -86,8 +86,9 @@ public async Task AcceptAsync_ClientClosesConnection_ServerNotified() // Assert var ex = await Assert.ThrowsAsync(() => acceptStreamTask.AsTask()).DefaultTimeout(); - var innerEx = Assert.IsType(ex.InnerException); - Assert.Equal(256, innerEx.ErrorCode); + var innerEx = Assert.IsType(ex.InnerException); + Assert.Equal(QuicError.ConnectionAborted, innerEx.QuicError); + Assert.Equal(256, innerEx.ApplicationErrorCode.Value); await connectionClosedTcs.Task.DefaultTimeout(); } @@ -252,8 +253,9 @@ public async Task AcceptAsync_ClientClosesConnection_ExceptionThrown() // Assert var ex = await Assert.ThrowsAsync(() => acceptTask).DefaultTimeout(); - var innerEx = Assert.IsType(ex.InnerException); - Assert.Equal((long)Http3ErrorCode.NoError, innerEx.ErrorCode); + var innerEx = Assert.IsType(ex.InnerException); + Assert.Equal(QuicError.ConnectionAborted, innerEx.QuicError); + Assert.Equal((long)Http3ErrorCode.NoError, innerEx.ApplicationErrorCode.Value); Assert.Equal((long)Http3ErrorCode.NoError, serverConnection.Features.Get().Error); } @@ -380,7 +382,7 @@ public async Task StreamPool_StreamAbortedOnClient_NotPooled() // Receive abort form client. var ex = await Assert.ThrowsAsync(() => serverStream.Transport.Input.ReadAsync().AsTask()).DefaultTimeout(); Assert.Equal("Stream aborted by peer (258).", ex.Message); - Assert.Equal((long)Http3ErrorCode.InternalError, ((QuicStreamAbortedException)ex.InnerException).ErrorCode); + Assert.Equal((long)Http3ErrorCode.InternalError, ((QuicException)ex.InnerException).ApplicationErrorCode.Value); // Complete reading and then abort. await serverStream.Transport.Input.CompleteAsync(); @@ -428,7 +430,7 @@ public async Task StreamPool_StreamAbortedOnClientAndServer_NotPooled() // Receive abort form client. var serverEx = await Assert.ThrowsAsync(() => serverStream.Transport.Input.ReadAsync().AsTask()).DefaultTimeout(); Assert.Equal("Stream aborted by peer (258).", serverEx.Message); - Assert.Equal((long)Http3ErrorCode.InternalError, ((QuicStreamAbortedException)serverEx.InnerException).ErrorCode); + Assert.Equal((long)Http3ErrorCode.InternalError, ((QuicException)serverEx.InnerException).ApplicationErrorCode.Value); serverStream.Features.Get().Error = (long)Http3ErrorCode.RequestRejected; serverStream.Abort(new ConnectionAbortedException("Test message.")); @@ -438,8 +440,9 @@ public async Task StreamPool_StreamAbortedOnClientAndServer_NotPooled() await serverStream.Transport.Output.CompleteAsync(); var buffer = new byte[1024]; - var clientEx = await Assert.ThrowsAsync(() => clientStream.ReadAsync(buffer).AsTask()).DefaultTimeout(); - Assert.Equal((long)Http3ErrorCode.RequestRejected, clientEx.ErrorCode); + var clientEx = await Assert.ThrowsAsync(() => clientStream.ReadAsync(buffer).AsTask()).DefaultTimeout(); + Assert.Equal(QuicError.StreamAborted, clientEx.QuicError); + Assert.Equal((long)Http3ErrorCode.RequestRejected, clientEx.ApplicationErrorCode.Value); var quicStreamContext = Assert.IsType(serverStream); diff --git a/src/Servers/Kestrel/Transport.Quic/test/QuicStreamContextTests.cs b/src/Servers/Kestrel/Transport.Quic/test/QuicStreamContextTests.cs index b024e5888459..e026d3563907 100644 --- a/src/Servers/Kestrel/Transport.Quic/test/QuicStreamContextTests.cs +++ b/src/Servers/Kestrel/Transport.Quic/test/QuicStreamContextTests.cs @@ -269,7 +269,7 @@ public async Task BidirectionalStream_ClientAbortWrite_ServerReceivesAbort() await serverStream.Transport.Output.CompleteAsync(); // Assert - Assert.Equal((long)Http3ErrorCode.InternalError, ((QuicStreamAbortedException)ex.InnerException).ErrorCode); + Assert.Equal((long)Http3ErrorCode.InternalError, ((QuicException)ex.InnerException).ApplicationErrorCode.Value); var quicStreamContext = Assert.IsType(serverStream); @@ -346,7 +346,7 @@ public async Task ClientToServerUnidirectionalStream_ClientAbort_ServerReceivesA var ex = await Assert.ThrowsAsync(() => serverStream.Transport.Input.ReadAsync().AsTask()).DefaultTimeout(); // Assert - Assert.Equal((long)Http3ErrorCode.InternalError, ((QuicStreamAbortedException)ex.InnerException).ErrorCode); + Assert.Equal((long)Http3ErrorCode.InternalError, ((QuicException)ex.InnerException).ApplicationErrorCode.Value); var quicStreamContext = Assert.IsType(serverStream); @@ -459,10 +459,11 @@ public async Task ServerToClientUnidirectionalStream_ServerAborts_ClientGetsAbor ((IProtocolErrorCodeFeature)serverStream).Error = (long)Http3ErrorCode.InternalError; serverStream.Abort(new ConnectionAbortedException("Test message")); - var ex = await Assert.ThrowsAsync(() => clientStream.ReadAsync(new byte[1024]).AsTask()).DefaultTimeout(); + var ex = await Assert.ThrowsAsync(() => clientStream.ReadAsync(new byte[1024]).AsTask()).DefaultTimeout(); // Assert - Assert.Equal((long)Http3ErrorCode.InternalError, ex.ErrorCode); + Assert.Equal(QuicError.StreamAborted, ex.QuicError); + Assert.Equal((long)Http3ErrorCode.InternalError, ex.ApplicationErrorCode.Value); var quicStreamContext = Assert.IsType(serverStream); Assert.True(quicStreamContext.CanWrite); @@ -514,8 +515,9 @@ public async Task StreamAbortFeature_AbortWrite_ClientReceivesAbort() Assert.Equal(TestData, data); // Client errors when writing - var clientEx = await Assert.ThrowsAsync(() => clientStream.WriteAsync(data).AsTask()).DefaultTimeout(); - Assert.Equal((long)Http3ErrorCode.InternalError, clientEx.ErrorCode); + var clientEx = await Assert.ThrowsAsync(() => clientStream.WriteAsync(data).AsTask()).DefaultTimeout(); + Assert.Equal(QuicError.StreamAborted, clientEx.QuicError); + Assert.Equal((long)Http3ErrorCode.InternalError, clientEx.ApplicationErrorCode.Value); // Server errors when reading var serverEx = await Assert.ThrowsAsync(() => serverReadTask).DefaultTimeout(); diff --git a/src/Servers/Kestrel/shared/test/TransportTestHelpers/HttpSysHttp3SupportedAttribute.cs b/src/Servers/Kestrel/shared/test/TransportTestHelpers/HttpSysHttp3SupportedAttribute.cs index cbfbfc6a4305..ebfac54cc22c 100644 --- a/src/Servers/Kestrel/shared/test/TransportTestHelpers/HttpSysHttp3SupportedAttribute.cs +++ b/src/Servers/Kestrel/shared/test/TransportTestHelpers/HttpSysHttp3SupportedAttribute.cs @@ -11,7 +11,9 @@ namespace Microsoft.AspNetCore.Testing; public class HttpSysHttp3SupportedAttribute : Attribute, ITestCondition { // We have the same OS and TLS version requirements as MsQuic so check that first. +#pragma warning disable CA2252 // This API requires opting into preview features public bool IsMet => QuicListener.IsSupported && IsRegKeySet; +#pragma warning restore CA2252 // This API requires opting into preview features public string SkipReason => "HTTP/3 is not supported or enabled on the current test machine"; diff --git a/src/Servers/Kestrel/shared/test/TransportTestHelpers/MsQuicSupportedAttribute.cs b/src/Servers/Kestrel/shared/test/TransportTestHelpers/MsQuicSupportedAttribute.cs index 362996ac7dd2..a4f31e605f7f 100644 --- a/src/Servers/Kestrel/shared/test/TransportTestHelpers/MsQuicSupportedAttribute.cs +++ b/src/Servers/Kestrel/shared/test/TransportTestHelpers/MsQuicSupportedAttribute.cs @@ -9,7 +9,9 @@ namespace Microsoft.AspNetCore.Testing; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)] public class MsQuicSupportedAttribute : Attribute, ITestCondition { +#pragma warning disable CA2252 // This API requires opting into preview features public bool IsMet => QuicListener.IsSupported; +#pragma warning restore CA2252 // This API requires opting into preview features public string SkipReason => "QUIC is not supported on the current test machine"; } diff --git a/src/Servers/Kestrel/stress/HttpStress.csproj b/src/Servers/Kestrel/stress/HttpStress.csproj index 9e0cf19b4e6a..7349608451e8 100644 --- a/src/Servers/Kestrel/stress/HttpStress.csproj +++ b/src/Servers/Kestrel/stress/HttpStress.csproj @@ -1,4 +1,4 @@ - + $(DefaultNetCoreTargetFramework) @@ -9,11 +9,9 @@ - - diff --git a/src/Servers/Kestrel/stress/Program.cs b/src/Servers/Kestrel/stress/Program.cs index b5ef3a14d636..20a0b35e0df3 100644 --- a/src/Servers/Kestrel/stress/Program.cs +++ b/src/Servers/Kestrel/stress/Program.cs @@ -372,7 +372,7 @@ Func TestAbort(string path) } Console.WriteLine(" .NET Core: " + Path.GetFileName(Path.GetDirectoryName(typeof(object).Assembly.Location))); - Console.WriteLine(" ASP.NET Core: " + Path.GetFileName(Path.GetDirectoryName(typeof(WebHost).Assembly.Location))); + Console.WriteLine(" ASP.NET Core: " + Path.GetFileName(Path.GetDirectoryName(typeof(IWebHostBuilder).Assembly.Location))); Console.WriteLine(" Tracing: " + (logPath == null ? (object)false : logPath.Length == 0 ? (object)true : logPath)); Console.WriteLine(" ASP.NET Log: " + aspnetLog); Console.WriteLine(" Concurrency: " + concurrentRequests); @@ -385,10 +385,11 @@ Func TestAbort(string path) // Start the Kestrel web server in-proc. Console.WriteLine("Starting server."); - WebHost.CreateDefaultBuilder() - + var host = Host.CreateDefaultBuilder(); + host.ConfigureWebHost(webHost => + { //Use Kestrel, and configure it for HTTPS with a self - signed test certificate. - .UseKestrel(ko => + webHost.UseKestrel(ko => { ko.ListenLocalhost(HttpsPort, listenOptions => { @@ -500,9 +501,11 @@ Func TestAbort(string path) await context.Request.Body.CopyToAsync(Stream.Null); }); }); - }) - .Build() - .Start(); + }); + + }) + .Build() + .Start(); // Start the client. Console.WriteLine($"Starting {concurrentRequests} client workers."); diff --git a/src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs b/src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs index 09bb48d76628..b56a5adf3615 100644 --- a/src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs +++ b/src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs @@ -436,8 +436,9 @@ public async Task POST_ServerAbort_ClientReceivesAbort(HttpProtocols protocol) // Assert if (protocol == HttpProtocols.Http3) { - var innerEx = Assert.IsType(ex.InnerException); - Assert.Equal(Http3ErrorCode.InternalError, (Http3ErrorCode)innerEx.ErrorCode); + var innerEx = Assert.IsType(ex.InnerException); + Assert.Equal(QuicError.StreamAborted, innerEx.QuicError); + Assert.Equal(Http3ErrorCode.InternalError, (Http3ErrorCode)innerEx.ApplicationErrorCode.Value); } await cancelledTcs.Task.DefaultTimeout(); @@ -493,8 +494,9 @@ public async Task GET_ServerAbort_ClientReceivesAbort(HttpProtocols protocol) // Assert if (protocol == HttpProtocols.Http3) { - var innerEx = Assert.IsType(ex.InnerException); - Assert.Equal(Http3ErrorCode.InternalError, (Http3ErrorCode)innerEx.ErrorCode); + var innerEx = Assert.IsType(ex.InnerException); + Assert.Equal(QuicError.StreamAborted, innerEx.QuicError); + Assert.Equal(Http3ErrorCode.InternalError, (Http3ErrorCode)innerEx.ApplicationErrorCode.Value); } await cancelledTcs.Task.DefaultTimeout(); diff --git a/src/Servers/Kestrel/test/Interop.FunctionalTests/Interop.FunctionalTests.csproj b/src/Servers/Kestrel/test/Interop.FunctionalTests/Interop.FunctionalTests.csproj index 404aeebc0a09..fb7ada2dbc40 100644 --- a/src/Servers/Kestrel/test/Interop.FunctionalTests/Interop.FunctionalTests.csproj +++ b/src/Servers/Kestrel/test/Interop.FunctionalTests/Interop.FunctionalTests.csproj @@ -8,6 +8,8 @@ false true true + + true