diff --git a/KestrelHttpServer.sln b/KestrelHttpServer.sln index 0440b242cf..09077ead0e 100644 --- a/KestrelHttpServer.sln +++ b/KestrelHttpServer.sln @@ -100,7 +100,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kestrel.Tests", "test\Kestr EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{A95C3BE1-B850-4265-97A0-777ADCCD437F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protocols.Abstractions", "src\Protocols.Abstractions\Protocols.Abstractions.csproj", "{6956CF5C-3163-4398-8628-4ECA569245B5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connections.Abstractions", "src\Connections.Abstractions\Connections.Abstractions.csproj", "{6956CF5C-3163-4398-8628-4ECA569245B5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{C2910A13-B2C2-46D8-81D8-7E166F4F5981}" ProjectSection(SolutionItems) = preProject diff --git a/benchmarks/Kestrel.Performance/InMemoryTransportBenchmark.cs b/benchmarks/Kestrel.Performance/InMemoryTransportBenchmark.cs index 0cf3e137a3..1816531088 100644 --- a/benchmarks/Kestrel.Performance/InMemoryTransportBenchmark.cs +++ b/benchmarks/Kestrel.Performance/InMemoryTransportBenchmark.cs @@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance _connectionsPerEndPoint = connectionsPerEndPoint; } - public ITransport Create(IEndPointInformation endPointInformation, IConnectionHandler handler) + public ITransport Create(IEndPointInformation endPointInformation, IConnectionDispatcher handler) { var connections = new InMemoryConnection[_connectionsPerEndPoint]; for (var i = 0; i < _connectionsPerEndPoint; i++) @@ -124,12 +124,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance public class InMemoryTransport : ITransport { - private readonly IConnectionHandler _handler; + private readonly IConnectionDispatcher _dispatcher; private readonly IReadOnlyList _connections; - public InMemoryTransport(IConnectionHandler handler, IReadOnlyList connections) + public InMemoryTransport(IConnectionDispatcher dispatcher, IReadOnlyList connections) { - _handler = handler; + _dispatcher = dispatcher; _connections = connections; } @@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance { foreach (var connection in _connections) { - _handler.OnConnection(connection); + _dispatcher.OnConnection(connection); } return Task.CompletedTask; diff --git a/src/Protocols.Abstractions/ConnectionBuilder.cs b/src/Connections.Abstractions/ConnectionBuilder.cs similarity index 96% rename from src/Protocols.Abstractions/ConnectionBuilder.cs rename to src/Connections.Abstractions/ConnectionBuilder.cs index 68efce703f..b75e92b60f 100644 --- a/src/Protocols.Abstractions/ConnectionBuilder.cs +++ b/src/Connections.Abstractions/ConnectionBuilder.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public class ConnectionBuilder : IConnectionBuilder { diff --git a/src/Protocols.Abstractions/ConnectionBuilderExtensions.cs b/src/Connections.Abstractions/ConnectionBuilderExtensions.cs similarity index 64% rename from src/Protocols.Abstractions/ConnectionBuilderExtensions.cs rename to src/Connections.Abstractions/ConnectionBuilderExtensions.cs index 9db3e4c468..100917b009 100644 --- a/src/Protocols.Abstractions/ConnectionBuilderExtensions.cs +++ b/src/Connections.Abstractions/ConnectionBuilderExtensions.cs @@ -3,11 +3,20 @@ using System; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public static class ConnectionBuilderExtensions { + public static IConnectionBuilder UseConnectionHandler(this IConnectionBuilder connectionBuilder) where TConnectionHandler : ConnectionHandler + { + var handler = ActivatorUtilities.GetServiceOrCreateInstance(connectionBuilder.ApplicationServices); + + // This is a terminal middleware, so there's no need to use the 'next' parameter + return connectionBuilder.Run(connection => handler.OnConnectedAsync(connection)); + } + public static IConnectionBuilder Use(this IConnectionBuilder connectionBuilder, Func, Task> middleware) { return connectionBuilder.Use(next => diff --git a/src/Protocols.Abstractions/ConnectionContext.cs b/src/Connections.Abstractions/ConnectionContext.cs similarity index 90% rename from src/Protocols.Abstractions/ConnectionContext.cs rename to src/Connections.Abstractions/ConnectionContext.cs index f8175d3897..aba4abdfc0 100644 --- a/src/Protocols.Abstractions/ConnectionContext.cs +++ b/src/Connections.Abstractions/ConnectionContext.cs @@ -2,7 +2,7 @@ using System.IO.Pipelines; using Microsoft.AspNetCore.Http.Features; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public abstract class ConnectionContext { diff --git a/src/Protocols.Abstractions/ConnectionDelegate.cs b/src/Connections.Abstractions/ConnectionDelegate.cs similarity index 72% rename from src/Protocols.Abstractions/ConnectionDelegate.cs rename to src/Connections.Abstractions/ConnectionDelegate.cs index ff0e4d75af..f0d64d1587 100644 --- a/src/Protocols.Abstractions/ConnectionDelegate.cs +++ b/src/Connections.Abstractions/ConnectionDelegate.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public delegate Task ConnectionDelegate(ConnectionContext connection); } diff --git a/src/Connections.Abstractions/ConnectionHandler.cs b/src/Connections.Abstractions/ConnectionHandler.cs new file mode 100644 index 0000000000..e9e208d61a --- /dev/null +++ b/src/Connections.Abstractions/ConnectionHandler.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Connections +{ + /// + /// Represents an end point that multiple connections connect to. For HTTP, endpoints are URLs, for non HTTP it can be a TCP listener (or similar) + /// + public abstract class ConnectionHandler + { + /// + /// Called when a new connection is accepted to the endpoint + /// + /// The new + /// A that represents the connection lifetime. When the task completes, the connection is complete. + public abstract Task OnConnectedAsync(ConnectionContext connection); + } +} \ No newline at end of file diff --git a/src/Protocols.Abstractions/Protocols.Abstractions.csproj b/src/Connections.Abstractions/Connections.Abstractions.csproj similarity index 53% rename from src/Protocols.Abstractions/Protocols.Abstractions.csproj rename to src/Connections.Abstractions/Connections.Abstractions.csproj index cd52227801..6e3235be54 100644 --- a/src/Protocols.Abstractions/Protocols.Abstractions.csproj +++ b/src/Connections.Abstractions/Connections.Abstractions.csproj @@ -1,8 +1,8 @@ - Microsoft.AspNetCore.Protocols.Abstractions - Microsoft.AspNetCore.Protocols.Abstractions + Microsoft.AspNetCore.Connections.Abstractions + Microsoft.AspNetCore.Connections.Abstractions Core components of ASP.NET Core networking protocol stack. netstandard2.0 true @@ -13,11 +13,8 @@ - - - - + diff --git a/src/Protocols.Abstractions/DefaultConnectionContext.cs b/src/Connections.Abstractions/DefaultConnectionContext.cs similarity index 94% rename from src/Protocols.Abstractions/DefaultConnectionContext.cs rename to src/Connections.Abstractions/DefaultConnectionContext.cs index 6959062e69..920efba18b 100644 --- a/src/Protocols.Abstractions/DefaultConnectionContext.cs +++ b/src/Connections.Abstractions/DefaultConnectionContext.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.IO.Pipelines; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols.Features; +using Microsoft.AspNetCore.Connections.Features; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public class DefaultConnectionContext : ConnectionContext { diff --git a/src/Protocols.Abstractions/DuplexPipe.cs b/src/Connections.Abstractions/DuplexPipe.cs similarity index 100% rename from src/Protocols.Abstractions/DuplexPipe.cs rename to src/Connections.Abstractions/DuplexPipe.cs diff --git a/src/Protocols.Abstractions/Exceptions/AddressInUseException.cs b/src/Connections.Abstractions/Exceptions/AddressInUseException.cs similarity index 91% rename from src/Protocols.Abstractions/Exceptions/AddressInUseException.cs rename to src/Connections.Abstractions/Exceptions/AddressInUseException.cs index 3a0dddc671..817abe8998 100644 --- a/src/Protocols.Abstractions/Exceptions/AddressInUseException.cs +++ b/src/Connections.Abstractions/Exceptions/AddressInUseException.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public class AddressInUseException : InvalidOperationException { diff --git a/src/Protocols.Abstractions/Exceptions/ConnectionAbortedException.cs b/src/Connections.Abstractions/Exceptions/ConnectionAbortedException.cs similarity index 91% rename from src/Protocols.Abstractions/Exceptions/ConnectionAbortedException.cs rename to src/Connections.Abstractions/Exceptions/ConnectionAbortedException.cs index b1119b9c2e..7615010cc7 100644 --- a/src/Protocols.Abstractions/Exceptions/ConnectionAbortedException.cs +++ b/src/Connections.Abstractions/Exceptions/ConnectionAbortedException.cs @@ -1,6 +1,6 @@ using System; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public class ConnectionAbortedException : OperationCanceledException { diff --git a/src/Protocols.Abstractions/Exceptions/ConnectionResetException.cs b/src/Connections.Abstractions/Exceptions/ConnectionResetException.cs similarity index 91% rename from src/Protocols.Abstractions/Exceptions/ConnectionResetException.cs rename to src/Connections.Abstractions/Exceptions/ConnectionResetException.cs index a19379628c..78765bc25a 100644 --- a/src/Protocols.Abstractions/Exceptions/ConnectionResetException.cs +++ b/src/Connections.Abstractions/Exceptions/ConnectionResetException.cs @@ -4,7 +4,7 @@ using System; using System.IO; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public class ConnectionResetException : IOException { diff --git a/src/Protocols.Abstractions/Features/IApplicationTransportFeature.cs b/src/Connections.Abstractions/Features/IApplicationTransportFeature.cs similarity index 87% rename from src/Protocols.Abstractions/Features/IApplicationTransportFeature.cs rename to src/Connections.Abstractions/Features/IApplicationTransportFeature.cs index 10f22d135e..e4955996c0 100644 --- a/src/Protocols.Abstractions/Features/IApplicationTransportFeature.cs +++ b/src/Connections.Abstractions/Features/IApplicationTransportFeature.cs @@ -5,7 +5,7 @@ using System.Buffers; using System.IO.Pipelines; using System.Threading; -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface IApplicationTransportFeature { diff --git a/src/Protocols.Abstractions/Features/IConnectionHeartbeatFeature.cs b/src/Connections.Abstractions/Features/IConnectionHeartbeatFeature.cs similarity index 85% rename from src/Protocols.Abstractions/Features/IConnectionHeartbeatFeature.cs rename to src/Connections.Abstractions/Features/IConnectionHeartbeatFeature.cs index 9770143a34..cea40d8bdc 100644 --- a/src/Protocols.Abstractions/Features/IConnectionHeartbeatFeature.cs +++ b/src/Connections.Abstractions/Features/IConnectionHeartbeatFeature.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface IConnectionHeartbeatFeature { diff --git a/src/Protocols.Abstractions/Features/IConnectionIdFeature.cs b/src/Connections.Abstractions/Features/IConnectionIdFeature.cs similarity index 83% rename from src/Protocols.Abstractions/Features/IConnectionIdFeature.cs rename to src/Connections.Abstractions/Features/IConnectionIdFeature.cs index 4c6cd81e77..2fa7ebbadf 100644 --- a/src/Protocols.Abstractions/Features/IConnectionIdFeature.cs +++ b/src/Connections.Abstractions/Features/IConnectionIdFeature.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface IConnectionIdFeature { diff --git a/src/Protocols.Abstractions/Features/IConnectionInherentKeepAliveFeature.cs b/src/Connections.Abstractions/Features/IConnectionInherentKeepAliveFeature.cs similarity index 95% rename from src/Protocols.Abstractions/Features/IConnectionInherentKeepAliveFeature.cs rename to src/Connections.Abstractions/Features/IConnectionInherentKeepAliveFeature.cs index cc3a211e46..8056dfa957 100644 --- a/src/Protocols.Abstractions/Features/IConnectionInherentKeepAliveFeature.cs +++ b/src/Connections.Abstractions/Features/IConnectionInherentKeepAliveFeature.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Text; -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { /// /// Indicates if the connection transport has an "inherent keep-alive", which means that the transport will automatically diff --git a/src/Protocols.Abstractions/Features/IConnectionItemsFeature.cs b/src/Connections.Abstractions/Features/IConnectionItemsFeature.cs similarity index 86% rename from src/Protocols.Abstractions/Features/IConnectionItemsFeature.cs rename to src/Connections.Abstractions/Features/IConnectionItemsFeature.cs index 136006b5a3..a3aef44310 100644 --- a/src/Protocols.Abstractions/Features/IConnectionItemsFeature.cs +++ b/src/Connections.Abstractions/Features/IConnectionItemsFeature.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface IConnectionItemsFeature { diff --git a/src/Protocols.Abstractions/Features/IConnectionTransportFeature.cs b/src/Connections.Abstractions/Features/IConnectionTransportFeature.cs similarity index 87% rename from src/Protocols.Abstractions/Features/IConnectionTransportFeature.cs rename to src/Connections.Abstractions/Features/IConnectionTransportFeature.cs index bf7067be23..7468dbc722 100644 --- a/src/Protocols.Abstractions/Features/IConnectionTransportFeature.cs +++ b/src/Connections.Abstractions/Features/IConnectionTransportFeature.cs @@ -5,7 +5,7 @@ using System.Buffers; using System.IO.Pipelines; using System.Threading; -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface IConnectionTransportFeature { diff --git a/src/Protocols.Abstractions/Features/IConnectionUserFeature.cs b/src/Connections.Abstractions/Features/IConnectionUserFeature.cs similarity index 71% rename from src/Protocols.Abstractions/Features/IConnectionUserFeature.cs rename to src/Connections.Abstractions/Features/IConnectionUserFeature.cs index 5daf9fd232..3efb362fc7 100644 --- a/src/Protocols.Abstractions/Features/IConnectionUserFeature.cs +++ b/src/Connections.Abstractions/Features/IConnectionUserFeature.cs @@ -1,6 +1,6 @@ using System.Security.Claims; -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface IConnectionUserFeature { diff --git a/src/Protocols.Abstractions/Features/IMemoryPoolFeature.cs b/src/Connections.Abstractions/Features/IMemoryPoolFeature.cs similarity index 86% rename from src/Protocols.Abstractions/Features/IMemoryPoolFeature.cs rename to src/Connections.Abstractions/Features/IMemoryPoolFeature.cs index 128b9ae3c9..0a7e28533e 100644 --- a/src/Protocols.Abstractions/Features/IMemoryPoolFeature.cs +++ b/src/Connections.Abstractions/Features/IMemoryPoolFeature.cs @@ -5,7 +5,7 @@ using System.Buffers; using System.IO.Pipelines; using System.Threading; -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface IMemoryPoolFeature { diff --git a/src/Protocols.Abstractions/Features/ITransferFormatFeature.cs b/src/Connections.Abstractions/Features/ITransferFormatFeature.cs similarity index 85% rename from src/Protocols.Abstractions/Features/ITransferFormatFeature.cs rename to src/Connections.Abstractions/Features/ITransferFormatFeature.cs index 72c262673f..ea39a92760 100644 --- a/src/Protocols.Abstractions/Features/ITransferFormatFeature.cs +++ b/src/Connections.Abstractions/Features/ITransferFormatFeature.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface ITransferFormatFeature { diff --git a/src/Protocols.Abstractions/Features/ITransportSchedulerFeature.cs b/src/Connections.Abstractions/Features/ITransportSchedulerFeature.cs similarity index 88% rename from src/Protocols.Abstractions/Features/ITransportSchedulerFeature.cs rename to src/Connections.Abstractions/Features/ITransportSchedulerFeature.cs index 05c8b8d605..e5d3a8e8d0 100644 --- a/src/Protocols.Abstractions/Features/ITransportSchedulerFeature.cs +++ b/src/Connections.Abstractions/Features/ITransportSchedulerFeature.cs @@ -5,7 +5,7 @@ using System.Buffers; using System.IO.Pipelines; using System.Threading; -namespace Microsoft.AspNetCore.Protocols.Features +namespace Microsoft.AspNetCore.Connections.Features { public interface ITransportSchedulerFeature { diff --git a/src/Protocols.Abstractions/IConnectionBuilder.cs b/src/Connections.Abstractions/IConnectionBuilder.cs similarity index 85% rename from src/Protocols.Abstractions/IConnectionBuilder.cs rename to src/Connections.Abstractions/IConnectionBuilder.cs index 15a028c5db..4825748292 100644 --- a/src/Protocols.Abstractions/IConnectionBuilder.cs +++ b/src/Connections.Abstractions/IConnectionBuilder.cs @@ -1,6 +1,6 @@ using System; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { public interface IConnectionBuilder { diff --git a/src/Protocols.Abstractions/TransferFormat.cs b/src/Connections.Abstractions/TransferFormat.cs similarity index 86% rename from src/Protocols.Abstractions/TransferFormat.cs rename to src/Connections.Abstractions/TransferFormat.cs index dd7cb28f64..03fd936159 100644 --- a/src/Protocols.Abstractions/TransferFormat.cs +++ b/src/Connections.Abstractions/TransferFormat.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Protocols +namespace Microsoft.AspNetCore.Connections { [Flags] public enum TransferFormat diff --git a/src/Kestrel.Core/Internal/AddressBinder.cs b/src/Kestrel.Core/Internal/AddressBinder.cs index 96ec14e51b..67ff4f1108 100644 --- a/src/Kestrel.Core/Internal/AddressBinder.cs +++ b/src/Kestrel.Core/Internal/AddressBinder.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.Extensions.Logging; diff --git a/src/Kestrel.Core/Internal/ConnectionLimitMiddleware.cs b/src/Kestrel.Core/Internal/ConnectionLimitMiddleware.cs index fd6823773f..5be3d5479a 100644 --- a/src/Kestrel.Core/Internal/ConnectionLimitMiddleware.cs +++ b/src/Kestrel.Core/Internal/ConnectionLimitMiddleware.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Features; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; diff --git a/src/Kestrel.Core/Internal/ConnectionHandler.cs b/src/Kestrel.Core/Internal/ConnectionListener.cs similarity index 91% rename from src/Kestrel.Core/Internal/ConnectionHandler.cs rename to src/Kestrel.Core/Internal/ConnectionListener.cs index db02fcd6ff..d3daa84158 100644 --- a/src/Kestrel.Core/Internal/ConnectionHandler.cs +++ b/src/Kestrel.Core/Internal/ConnectionListener.cs @@ -7,20 +7,20 @@ using System.IO.Pipelines; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols; -using Microsoft.AspNetCore.Protocols.Features; +using Microsoft.AspNetCore.Connections; +using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal { - public class ConnectionHandler : IConnectionHandler + public class ConnectionDispatcher : IConnectionDispatcher { private readonly ServiceContext _serviceContext; private readonly ConnectionDelegate _connectionDelegate; - public ConnectionHandler(ServiceContext serviceContext, ConnectionDelegate connectionDelegate) + public ConnectionDispatcher(ServiceContext serviceContext, ConnectionDelegate connectionDelegate) { _serviceContext = serviceContext; _connectionDelegate = connectionDelegate; @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal } catch (Exception ex) { - Log.LogCritical(0, ex, $"{nameof(ConnectionHandler)}.{nameof(Execute)}() {connectionContext.ConnectionId}"); + Log.LogCritical(0, ex, $"{nameof(ConnectionDispatcher)}.{nameof(Execute)}() {connectionContext.ConnectionId}"); } Log.ConnectionStop(connectionContext.ConnectionId); diff --git a/src/Kestrel.Core/Internal/Http/Http1Connection.cs b/src/Kestrel.Core/Internal/Http/Http1Connection.cs index d0105f9bfe..c6215fb1a4 100644 --- a/src/Kestrel.Core/Internal/Http/Http1Connection.cs +++ b/src/Kestrel.Core/Internal/Http/Http1Connection.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols.Abstractions; +using Microsoft.AspNetCore.Connections.Abstractions; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http diff --git a/src/Kestrel.Core/Internal/Http/Http1MessageBody.cs b/src/Kestrel.Core/Internal/Http/Http1MessageBody.cs index 5ac13c69a4..54d400d3a9 100644 --- a/src/Kestrel.Core/Internal/Http/Http1MessageBody.cs +++ b/src/Kestrel.Core/Internal/Http/Http1MessageBody.cs @@ -8,7 +8,7 @@ using System.IO; using System.IO.Pipelines; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Protocols.Abstractions; +using Microsoft.AspNetCore.Connections.Abstractions; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http diff --git a/src/Kestrel.Core/Internal/Http/HttpProtocol.cs b/src/Kestrel.Core/Internal/Http/HttpProtocol.cs index 01bde85605..6bb16e24df 100644 --- a/src/Kestrel.Core/Internal/Http/HttpProtocol.cs +++ b/src/Kestrel.Core/Internal/Http/HttpProtocol.cs @@ -16,7 +16,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; diff --git a/src/Kestrel.Core/Internal/Http/HttpRequestStream.cs b/src/Kestrel.Core/Internal/Http/HttpRequestStream.cs index 2c47fad114..8ea4e9f922 100644 --- a/src/Kestrel.Core/Internal/Http/HttpRequestStream.cs +++ b/src/Kestrel.Core/Internal/Http/HttpRequestStream.cs @@ -7,7 +7,7 @@ using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http diff --git a/src/Kestrel.Core/Internal/Http/UrlDecoder.cs b/src/Kestrel.Core/Internal/Http/UrlDecoder.cs index fcdb3cfef6..e5ed2c86fa 100644 --- a/src/Kestrel.Core/Internal/Http/UrlDecoder.cs +++ b/src/Kestrel.Core/Internal/Http/UrlDecoder.cs @@ -4,7 +4,7 @@ using System; -namespace Microsoft.AspNetCore.Protocols.Abstractions +namespace Microsoft.AspNetCore.Connections.Abstractions { internal class UrlDecoder { diff --git a/src/Kestrel.Core/Internal/Http2/Http2Connection.cs b/src/Kestrel.Core/Internal/Http2/Http2Connection.cs index 0e1928720f..549e804d33 100644 --- a/src/Kestrel.Core/Internal/Http2/Http2Connection.cs +++ b/src/Kestrel.Core/Internal/Http2/Http2Connection.cs @@ -10,7 +10,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.HPack; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; diff --git a/src/Kestrel.Core/Internal/HttpConnectionBuilderExtensions.cs b/src/Kestrel.Core/Internal/HttpConnectionBuilderExtensions.cs index ed57343f27..dcd073855b 100644 --- a/src/Kestrel.Core/Internal/HttpConnectionBuilderExtensions.cs +++ b/src/Kestrel.Core/Internal/HttpConnectionBuilderExtensions.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using Microsoft.AspNetCore.Hosting.Server; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal diff --git a/src/Kestrel.Core/Internal/HttpConnectionMiddleware.cs b/src/Kestrel.Core/Internal/HttpConnectionMiddleware.cs index 3be295627d..87ae45c154 100644 --- a/src/Kestrel.Core/Internal/HttpConnectionMiddleware.cs +++ b/src/Kestrel.Core/Internal/HttpConnectionMiddleware.cs @@ -4,8 +4,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols; -using Microsoft.AspNetCore.Protocols.Features; +using Microsoft.AspNetCore.Connections; +using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal diff --git a/src/Kestrel.Core/Internal/Infrastructure/HttpConnectionManagerShutdownExtensions.cs b/src/Kestrel.Core/Internal/Infrastructure/HttpConnectionManagerShutdownExtensions.cs index 40e41874c4..24400fedef 100644 --- a/src/Kestrel.Core/Internal/Infrastructure/HttpConnectionManagerShutdownExtensions.cs +++ b/src/Kestrel.Core/Internal/Infrastructure/HttpConnectionManagerShutdownExtensions.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure { diff --git a/src/Kestrel.Core/Kestrel.Core.csproj b/src/Kestrel.Core/Kestrel.Core.csproj index 68a0b5aaf5..b81428efa5 100644 --- a/src/Kestrel.Core/Kestrel.Core.csproj +++ b/src/Kestrel.Core/Kestrel.Core.csproj @@ -24,6 +24,7 @@ + diff --git a/src/Kestrel.Core/KestrelServer.cs b/src/Kestrel.Core/KestrelServer.cs index 2ab8472cc3..9e549a2282 100644 --- a/src/Kestrel.Core/KestrelServer.cs +++ b/src/Kestrel.Core/KestrelServer.cs @@ -148,8 +148,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core connectionDelegate = new ConnectionLimitMiddleware(connectionDelegate, Options.Limits.MaxConcurrentConnections.Value, Trace).OnConnectionAsync; } - var connectionHandler = new ConnectionHandler(ServiceContext, connectionDelegate); - var transport = _transportFactory.Create(endpoint, connectionHandler); + var connectionDispatcher = new ConnectionDispatcher(ServiceContext, connectionDelegate); + var transport = _transportFactory.Create(endpoint, connectionDispatcher); _transports.Add(transport); await transport.BindAsync().ConfigureAwait(false); diff --git a/src/Kestrel.Core/ListenOptions.cs b/src/Kestrel.Core/ListenOptions.cs index 0ed675aac8..bdef463d60 100644 --- a/src/Kestrel.Core/ListenOptions.cs +++ b/src/Kestrel.Core/ListenOptions.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Threading.Tasks; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; diff --git a/src/Kestrel.Transport.Abstractions/Internal/IConnectionHandler.cs b/src/Kestrel.Transport.Abstractions/Internal/IConnectionDispatcher.cs similarity index 89% rename from src/Kestrel.Transport.Abstractions/Internal/IConnectionHandler.cs rename to src/Kestrel.Transport.Abstractions/Internal/IConnectionDispatcher.cs index eec71ff61c..05b7d84ea2 100644 --- a/src/Kestrel.Transport.Abstractions/Internal/IConnectionHandler.cs +++ b/src/Kestrel.Transport.Abstractions/Internal/IConnectionDispatcher.cs @@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Http.Features; namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal { - public interface IConnectionHandler + public interface IConnectionDispatcher { void OnConnection(TransportConnection connection); } diff --git a/src/Kestrel.Transport.Abstractions/Internal/ITransportFactory.cs b/src/Kestrel.Transport.Abstractions/Internal/ITransportFactory.cs index 326b6c1cfc..4037467e87 100644 --- a/src/Kestrel.Transport.Abstractions/Internal/ITransportFactory.cs +++ b/src/Kestrel.Transport.Abstractions/Internal/ITransportFactory.cs @@ -5,6 +5,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal { public interface ITransportFactory { - ITransport Create(IEndPointInformation endPointInformation, IConnectionHandler handler); + ITransport Create(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher); } } diff --git a/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.Features.cs b/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.Features.cs index c9e316557f..8ab96ba108 100644 --- a/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.Features.cs +++ b/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.Features.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO.Pipelines; using System.Net; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols.Features; +using Microsoft.AspNetCore.Connections.Features; namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal { diff --git a/src/Kestrel.Transport.Abstractions/Kestrel.Transport.Abstractions.csproj b/src/Kestrel.Transport.Abstractions/Kestrel.Transport.Abstractions.csproj index b8877c964a..58529f72d0 100644 --- a/src/Kestrel.Transport.Abstractions/Kestrel.Transport.Abstractions.csproj +++ b/src/Kestrel.Transport.Abstractions/Kestrel.Transport.Abstractions.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Kestrel.Transport.Libuv/Internal/LibuvConnection.cs b/src/Kestrel.Transport.Libuv/Internal/LibuvConnection.cs index b5df138e61..b6295aa568 100644 --- a/src/Kestrel.Transport.Libuv/Internal/LibuvConnection.cs +++ b/src/Kestrel.Transport.Libuv/Internal/LibuvConnection.cs @@ -7,7 +7,7 @@ using System.IO; using System.IO.Pipelines; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking; using Microsoft.Extensions.Logging; @@ -48,14 +48,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal public LibuvOutputConsumer OutputConsumer { get; set; } private ILibuvTrace Log => ListenerContext.TransportContext.Log; - private IConnectionHandler ConnectionHandler => ListenerContext.TransportContext.ConnectionHandler; + private IConnectionDispatcher ConnectionDispatcher => ListenerContext.TransportContext.ConnectionDispatcher; private LibuvThread Thread => ListenerContext.Thread; public async Task Start() { try { - ConnectionHandler.OnConnection(this); + ConnectionDispatcher.OnConnection(this); OutputConsumer = new LibuvOutputConsumer(Output, Thread, _socket, ConnectionId, Log); diff --git a/src/Kestrel.Transport.Libuv/Internal/LibuvTransportContext.cs b/src/Kestrel.Transport.Libuv/Internal/LibuvTransportContext.cs index 9256c85048..37074dc968 100644 --- a/src/Kestrel.Transport.Libuv/Internal/LibuvTransportContext.cs +++ b/src/Kestrel.Transport.Libuv/Internal/LibuvTransportContext.cs @@ -14,6 +14,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal public ILibuvTrace Log { get; set; } - public IConnectionHandler ConnectionHandler { get; set; } + public IConnectionDispatcher ConnectionDispatcher { get; set; } } } diff --git a/src/Kestrel.Transport.Libuv/LibuvTransport.cs b/src/Kestrel.Transport.Libuv/LibuvTransport.cs index 19eb6cf72e..35def2dc55 100644 --- a/src/Kestrel.Transport.Libuv/LibuvTransport.cs +++ b/src/Kestrel.Transport.Libuv/LibuvTransport.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking; diff --git a/src/Kestrel.Transport.Libuv/LibuvTransportFactory.cs b/src/Kestrel.Transport.Libuv/LibuvTransportFactory.cs index a698388bea..418f43abd8 100644 --- a/src/Kestrel.Transport.Libuv/LibuvTransportFactory.cs +++ b/src/Kestrel.Transport.Libuv/LibuvTransportFactory.cs @@ -62,14 +62,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv }; } - public ITransport Create(IEndPointInformation endPointInformation, IConnectionHandler handler) + public ITransport Create(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher) { var transportContext = new LibuvTransportContext { Options = _baseTransportContext.Options, AppLifetime = _baseTransportContext.AppLifetime, Log = _baseTransportContext.Log, - ConnectionHandler = handler + ConnectionDispatcher = dispatcher }; return new LibuvTransport(transportContext, endPointInformation); diff --git a/src/Kestrel.Transport.Sockets/Internal/SocketConnection.cs b/src/Kestrel.Transport.Sockets/Internal/SocketConnection.cs index a70ec03f46..726d0372ca 100644 --- a/src/Kestrel.Transport.Sockets/Internal/SocketConnection.cs +++ b/src/Kestrel.Transport.Sockets/Internal/SocketConnection.cs @@ -10,7 +10,7 @@ using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; using System.Threading.Tasks; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.Extensions.Logging; @@ -60,12 +60,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal public override PipeScheduler InputWriterScheduler => _scheduler; public override PipeScheduler OutputReaderScheduler => _scheduler; - public async Task StartAsync(IConnectionHandler connectionHandler) + public async Task StartAsync(IConnectionDispatcher connectionDispatcher) { Exception sendError = null; try { - connectionHandler.OnConnection(this); + connectionDispatcher.OnConnection(this); // Spawn send and receive logic Task receiveTask = DoReceive(); diff --git a/src/Kestrel.Transport.Sockets/SocketTransport.cs b/src/Kestrel.Transport.Sockets/SocketTransport.cs index 9a11e03a0f..725ee0546d 100644 --- a/src/Kestrel.Transport.Sockets/SocketTransport.cs +++ b/src/Kestrel.Transport.Sockets/SocketTransport.cs @@ -11,7 +11,7 @@ using System.Runtime.ExceptionServices; using System.Runtime.InteropServices; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal; using Microsoft.Extensions.Logging; @@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets private readonly MemoryPool _memoryPool = KestrelMemoryPool.Create(); private readonly IEndPointInformation _endPointInformation; - private readonly IConnectionHandler _handler; + private readonly IConnectionDispatcher _dispatcher; private readonly IApplicationLifetime _appLifetime; private readonly int _numSchedulers; private readonly PipeScheduler[] _schedulers; @@ -36,19 +36,19 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets internal SocketTransport( IEndPointInformation endPointInformation, - IConnectionHandler handler, + IConnectionDispatcher dispatcher, IApplicationLifetime applicationLifetime, int ioQueueCount, ISocketsTrace trace) { Debug.Assert(endPointInformation != null); Debug.Assert(endPointInformation.Type == ListenType.IPEndPoint); - Debug.Assert(handler != null); + Debug.Assert(dispatcher != null); Debug.Assert(applicationLifetime != null); Debug.Assert(trace != null); _endPointInformation = endPointInformation; - _handler = handler; + _dispatcher = dispatcher; _appLifetime = applicationLifetime; _trace = trace; @@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets acceptSocket.NoDelay = _endPointInformation.NoDelay; var connection = new SocketConnection(acceptSocket, _memoryPool, _schedulers[schedulerIndex], _trace); - _ = connection.StartAsync(_handler); + _ = connection.StartAsync(_dispatcher); } catch (SocketException ex) when (ex.SocketErrorCode == SocketError.ConnectionReset) { diff --git a/src/Kestrel.Transport.Sockets/SocketTransportFactory.cs b/src/Kestrel.Transport.Sockets/SocketTransportFactory.cs index 473a1519cc..7ddd1d918d 100644 --- a/src/Kestrel.Transport.Sockets/SocketTransportFactory.cs +++ b/src/Kestrel.Transport.Sockets/SocketTransportFactory.cs @@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets _trace = new SocketsTrace(logger); } - public ITransport Create(IEndPointInformation endPointInformation, IConnectionHandler handler) + public ITransport Create(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher) { if (endPointInformation == null) { @@ -52,12 +52,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets throw new ArgumentException(SocketsStrings.OnlyIPEndPointsSupported, nameof(endPointInformation)); } - if (handler == null) + if (dispatcher == null) { - throw new ArgumentNullException(nameof(handler)); + throw new ArgumentNullException(nameof(dispatcher)); } - return new SocketTransport(endPointInformation, handler, _appLifetime, _options.IOQueueCount, _trace); + return new SocketTransport(endPointInformation, dispatcher, _appLifetime, _options.IOQueueCount, _trace); } } } diff --git a/test/Kestrel.Core.Tests/AddressBinderTests.cs b/test/Kestrel.Core.Tests/AddressBinderTests.cs index 9308c8c14b..426e490502 100644 --- a/test/Kestrel.Core.Tests/AddressBinderTests.cs +++ b/test/Kestrel.Core.Tests/AddressBinderTests.cs @@ -5,7 +5,7 @@ using System; using System.IO; using System.Net; using System.Threading.Tasks; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.AspNetCore.Testing; diff --git a/test/Kestrel.Core.Tests/ConnectionHandlerTests.cs b/test/Kestrel.Core.Tests/ConnectionDispatcherTests.cs similarity index 89% rename from test/Kestrel.Core.Tests/ConnectionHandlerTests.cs rename to test/Kestrel.Core.Tests/ConnectionDispatcherTests.cs index 27128fe558..9f53e16750 100644 --- a/test/Kestrel.Core.Tests/ConnectionHandlerTests.cs +++ b/test/Kestrel.Core.Tests/ConnectionDispatcherTests.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols.Features; +using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; @@ -14,18 +14,18 @@ using Xunit; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { - public class ConnectionHandlerTests + public class ConnectionDispatcherTests { [Fact] public void OnConnectionCreatesLogScopeWithConnectionId() { var serviceContext = new TestServiceContext(); var tcs = new TaskCompletionSource(); - var handler = new ConnectionHandler(serviceContext, _ => tcs.Task); + var dispatcher = new ConnectionDispatcher(serviceContext, _ => tcs.Task); var connection = new TestConnection(); - handler.OnConnection(connection); + dispatcher.OnConnection(connection); // The scope should be created var scopeObjects = ((TestKestrelTrace)serviceContext.Log) diff --git a/test/Kestrel.Core.Tests/Http2ConnectionTests.cs b/test/Kestrel.Core.Tests/Http2ConnectionTests.cs index 46af33c2dc..341c9b21e6 100644 --- a/test/Kestrel.Core.Tests/Http2ConnectionTests.cs +++ b/test/Kestrel.Core.Tests/Http2ConnectionTests.cs @@ -12,7 +12,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Features; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2; diff --git a/test/Kestrel.Core.Tests/KestrelServerTests.cs b/test/Kestrel.Core.Tests/KestrelServerTests.cs index fefd6bce51..10de4f2fa6 100644 --- a/test/Kestrel.Core.Tests/KestrelServerTests.cs +++ b/test/Kestrel.Core.Tests/KestrelServerTests.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Contains(server.Options.ListenOptions[0].ConnectionAdapters, adapter => adapter.IsHttps); } } - + [Fact] public void KestrelServerThrowsUsefulExceptionIfDefaultHttpsProviderNotAdded() { @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(CoreStrings.NoCertSpecifiedNoDevelopmentCertificateFound, ex.Message); } } - + [Fact] public void KestrelServerDoesNotThrowIfNoDefaultHttpsProviderButNoHttpUrls() { @@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests StartDummyApplication(server); } } - + [Fact] public void KestrelServerDoesNotThrowIfNoDefaultHttpsProviderButManualListenOptions() { @@ -241,7 +241,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests var mockTransportFactory = new Mock(); mockTransportFactory - .Setup(transportFactory => transportFactory.Create(It.IsAny(), It.IsAny())) + .Setup(transportFactory => transportFactory.Create(It.IsAny(), It.IsAny())) .Returns(mockTransport.Object); var mockLoggerFactory = new Mock(); @@ -298,7 +298,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests var mockTransportFactory = new Mock(); mockTransportFactory - .Setup(transportFactory => transportFactory.Create(It.IsAny(), It.IsAny())) + .Setup(transportFactory => transportFactory.Create(It.IsAny(), It.IsAny())) .Returns(mockTransport.Object); var mockLoggerFactory = new Mock(); @@ -342,7 +342,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests private class MockTransportFactory : ITransportFactory { - public ITransport Create(IEndPointInformation endPointInformation, IConnectionHandler handler) + public ITransport Create(IEndPointInformation endPointInformation, IConnectionDispatcher handler) { return Mock.Of(); } diff --git a/test/Kestrel.Core.Tests/PipeOptionsTests.cs b/test/Kestrel.Core.Tests/PipeOptionsTests.cs index 0a15d06491..3643fc44ba 100644 --- a/test/Kestrel.Core.Tests/PipeOptionsTests.cs +++ b/test/Kestrel.Core.Tests/PipeOptionsTests.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests serviceContext.Scheduler = PipeScheduler.ThreadPool; var mockScheduler = Mock.Of(); - var outputPipeOptions = ConnectionHandler.GetOutputPipeOptions(serviceContext, KestrelMemoryPool.Create(), readerScheduler: mockScheduler); + var outputPipeOptions = ConnectionDispatcher.GetOutputPipeOptions(serviceContext, KestrelMemoryPool.Create(), readerScheduler: mockScheduler); Assert.Equal(expectedMaximumSizeLow, outputPipeOptions.ResumeWriterThreshold); Assert.Equal(expectedMaximumSizeHigh, outputPipeOptions.PauseWriterThreshold); @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests serviceContext.Scheduler = PipeScheduler.ThreadPool; var mockScheduler = Mock.Of(); - var inputPipeOptions = ConnectionHandler.GetInputPipeOptions(serviceContext, KestrelMemoryPool.Create(), writerScheduler: mockScheduler); + var inputPipeOptions = ConnectionDispatcher.GetInputPipeOptions(serviceContext, KestrelMemoryPool.Create(), writerScheduler: mockScheduler); Assert.Equal(expectedMaximumSizeLow, inputPipeOptions.ResumeWriterThreshold); Assert.Equal(expectedMaximumSizeHigh, inputPipeOptions.PauseWriterThreshold); diff --git a/test/Kestrel.FunctionalTests/RequestTests.cs b/test/Kestrel.FunctionalTests/RequestTests.cs index 673cf42ff8..8aefc5f786 100644 --- a/test/Kestrel.FunctionalTests/RequestTests.cs +++ b/test/Kestrel.FunctionalTests/RequestTests.cs @@ -18,7 +18,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core.Features; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; diff --git a/test/Kestrel.Transport.Libuv.Tests/LibuvConnectionTests.cs b/test/Kestrel.Transport.Libuv.Tests/LibuvConnectionTests.cs index 2eeec77ab7..7a82e6da15 100644 --- a/test/Kestrel.Transport.Libuv.Tests/LibuvConnectionTests.cs +++ b/test/Kestrel.Transport.Libuv.Tests/LibuvConnectionTests.cs @@ -19,9 +19,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests [Fact] public async Task DoesNotEndConnectionOnZeroRead() { - var mockConnectionHandler = new MockConnectionHandler(); + var mockConnectionDispatcher = new MockConnectionDispatcher(); var mockLibuv = new MockLibuv(); - var transportContext = new TestLibuvTransportContext() { ConnectionHandler = mockConnectionHandler }; + var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher }; var transport = new LibuvTransport(mockLibuv, transportContext, null); var thread = new LibuvThread(transport); @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests mockLibuv.ReadCallback(socket.InternalGetHandle(), 0, ref ignored); }, (object)null); - var readAwaitable = mockConnectionHandler.Input.Reader.ReadAsync(); + var readAwaitable = mockConnectionDispatcher.Input.Reader.ReadAsync(); Assert.False(readAwaitable.IsCompleted); } finally @@ -54,12 +54,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests [Fact] public async Task ConnectionDoesNotResumeAfterSocketCloseIfBackpressureIsApplied() { - var mockConnectionHandler = new MockConnectionHandler(); + var mockConnectionDispatcher = new MockConnectionDispatcher(); var mockLibuv = new MockLibuv(); - var transportContext = new TestLibuvTransportContext() { ConnectionHandler = mockConnectionHandler }; + var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher }; var transport = new LibuvTransport(mockLibuv, transportContext, null); var thread = new LibuvThread(transport); - mockConnectionHandler.InputOptions = pool => + mockConnectionDispatcher.InputOptions = pool => new PipeOptions( pool: pool, pauseWriterThreshold: 3, @@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests // We don't set the output writer scheduler here since we want to run the callback inline - mockConnectionHandler.OutputOptions = pool => new PipeOptions(pool: pool, readerScheduler: thread, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); + mockConnectionDispatcher.OutputOptions = pool => new PipeOptions(pool: pool, readerScheduler: thread, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); Task connectionTask = null; @@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests Assert.Null(mockLibuv.ReadCallback); // Now complete the output writer so that the connection closes - mockConnectionHandler.Output.Writer.Complete(); + mockConnectionDispatcher.Output.Writer.Complete(); await connectionTask.TimeoutAfter(TestConstants.DefaultTimeout); @@ -115,9 +115,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests [Fact] public async Task ConnectionDoesNotResumeAfterReadCallbackScheduledAndSocketCloseIfBackpressureIsApplied() { - var mockConnectionHandler = new MockConnectionHandler(); + var mockConnectionDispatcher = new MockConnectionDispatcher(); var mockLibuv = new MockLibuv(); - var transportContext = new TestLibuvTransportContext() { ConnectionHandler = mockConnectionHandler }; + var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher }; var transport = new LibuvTransport(mockLibuv, transportContext, null); var thread = new LibuvThread(transport); var mockScheduler = new Mock(); @@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests { backPressure = () => a(o); }); - mockConnectionHandler.InputOptions = pool => + mockConnectionDispatcher.InputOptions = pool => new PipeOptions( pool: pool, pauseWriterThreshold: 3, @@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests readerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); - mockConnectionHandler.OutputOptions = pool => new PipeOptions(pool: pool, readerScheduler: thread, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); + mockConnectionDispatcher.OutputOptions = pool => new PipeOptions(pool: pool, readerScheduler: thread, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); Task connectionTask = null; try @@ -163,13 +163,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests Assert.Null(mockLibuv.ReadCallback); // Now release backpressure by reading the input - var result = await mockConnectionHandler.Input.Reader.ReadAsync(); + var result = await mockConnectionDispatcher.Input.Reader.ReadAsync(); // Calling advance will call into our custom scheduler that captures the back pressure // callback - mockConnectionHandler.Input.Reader.AdvanceTo(result.Buffer.End); + mockConnectionDispatcher.Input.Reader.AdvanceTo(result.Buffer.End); // Cancel the current pending flush - mockConnectionHandler.Input.Writer.CancelPendingFlush(); + mockConnectionDispatcher.Input.Writer.CancelPendingFlush(); // Now release the back pressure await thread.PostAsync(a => a(), backPressure); @@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests Assert.Null(mockLibuv.ReadCallback); // Now complete the output writer and wait for the connection to close - mockConnectionHandler.Output.Writer.Complete(); + mockConnectionDispatcher.Output.Writer.Complete(); await connectionTask.TimeoutAfter(TestConstants.DefaultTimeout); @@ -196,9 +196,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests [Fact] public async Task DoesNotThrowIfOnReadCallbackCalledWithEOFButAllocCallbackNotCalled() { - var mockConnectionHandler = new MockConnectionHandler(); + var mockConnectionDispatcher = new MockConnectionDispatcher(); var mockLibuv = new MockLibuv(); - var transportContext = new TestLibuvTransportContext() { ConnectionHandler = mockConnectionHandler }; + var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher }; var transport = new LibuvTransport(mockLibuv, transportContext, null); var thread = new LibuvThread(transport); @@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests mockLibuv.ReadCallback(socket.InternalGetHandle(), TestConstants.EOF, ref ignored); }, (object)null); - var readAwaitable = await mockConnectionHandler.Input.Reader.ReadAsync(); + var readAwaitable = await mockConnectionDispatcher.Input.Reader.ReadAsync(); Assert.True(readAwaitable.IsCompleted); } finally diff --git a/test/Kestrel.Transport.Libuv.Tests/LibuvThreadTests.cs b/test/Kestrel.Transport.Libuv.Tests/LibuvThreadTests.cs index db3b3ebd8f..5177420d9c 100644 --- a/test/Kestrel.Transport.Libuv.Tests/LibuvThreadTests.cs +++ b/test/Kestrel.Transport.Libuv.Tests/LibuvThreadTests.cs @@ -18,9 +18,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests [Fact] public async Task LibuvThreadDoesNotThrowIfPostingWorkAfterDispose() { - var mockConnectionHandler = new MockConnectionHandler(); + var mockConnectionDispatcher = new MockConnectionDispatcher(); var mockLibuv = new MockLibuv(); - var transportContext = new TestLibuvTransportContext() { ConnectionHandler = mockConnectionHandler }; + var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher }; var transport = new LibuvTransport(mockLibuv, transportContext, null); var thread = new LibuvThread(transport); var ranOne = false; diff --git a/test/Kestrel.Transport.Libuv.Tests/LibuvTransportTests.cs b/test/Kestrel.Transport.Libuv.Tests/LibuvTransportTests.cs index 3f478546da..388f78e3ba 100644 --- a/test/Kestrel.Transport.Libuv.Tests/LibuvTransportTests.cs +++ b/test/Kestrel.Transport.Libuv.Tests/LibuvTransportTests.cs @@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var transportContext = new TestLibuvTransportContext() { - ConnectionHandler = new ConnectionHandler(serviceContext, listenOptions.Build()) + ConnectionDispatcher = new ConnectionDispatcher(serviceContext, listenOptions.Build()) }; var transport = new LibuvTransport(transportContext, listenOptions); @@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var transportContext = new TestLibuvTransportContext() { - ConnectionHandler = new ConnectionHandler(serviceContext, listenOptions.Build()), + ConnectionDispatcher = new ConnectionDispatcher(serviceContext, listenOptions.Build()), Options = new LibuvTransportOptions { ThreadCount = threadCount } }; diff --git a/test/Kestrel.Transport.Libuv.Tests/ListenerPrimaryTests.cs b/test/Kestrel.Transport.Libuv.Tests/ListenerPrimaryTests.cs index cd243e815b..fa4198ccb4 100644 --- a/test/Kestrel.Transport.Libuv.Tests/ListenerPrimaryTests.cs +++ b/test/Kestrel.Transport.Libuv.Tests/ListenerPrimaryTests.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Protocols; +using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; @@ -34,13 +34,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var transportContextPrimary = new TestLibuvTransportContext(); var builderPrimary = new ConnectionBuilder(); builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1); - transportContextPrimary.ConnectionHandler = new ConnectionHandler(serviceContextPrimary, builderPrimary.Build()); + transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build()); var serviceContextSecondary = new TestServiceContext(); var builderSecondary = new ConnectionBuilder(); builderSecondary.UseHttpServer(serviceContextSecondary, new DummyApplication(c => c.Response.WriteAsync("Secondary")), HttpProtocols.Http1); var transportContextSecondary = new TestLibuvTransportContext(); - transportContextSecondary.ConnectionHandler = new ConnectionHandler(serviceContextSecondary, builderSecondary.Build()); + transportContextSecondary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextSecondary, builderSecondary.Build()); var libuvTransport = new LibuvTransport(libuv, transportContextPrimary, listenOptions); @@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var builderPrimary = new ConnectionBuilder(); builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1); var transportContextPrimary = new TestLibuvTransportContext() { Log = new LibuvTrace(logger) }; - transportContextPrimary.ConnectionHandler = new ConnectionHandler(serviceContextPrimary, builderPrimary.Build()); + transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build()); var serviceContextSecondary = new TestServiceContext { @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var builderSecondary = new ConnectionBuilder(); builderSecondary.UseHttpServer(serviceContextSecondary, new DummyApplication(c => c.Response.WriteAsync("Secondary")), HttpProtocols.Http1); var transportContextSecondary = new TestLibuvTransportContext(); - transportContextSecondary.ConnectionHandler = new ConnectionHandler(serviceContextSecondary, builderSecondary.Build()); + transportContextSecondary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextSecondary, builderSecondary.Build()); var libuvTransport = new LibuvTransport(libuv, transportContextPrimary, listenOptions); @@ -214,7 +214,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var builderPrimary = new ConnectionBuilder(); builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1); var transportContextPrimary = new TestLibuvTransportContext() { Log = new LibuvTrace(logger) }; - transportContextPrimary.ConnectionHandler = new ConnectionHandler(serviceContextPrimary, builderPrimary.Build()); + transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build()); var serviceContextSecondary = new TestServiceContext { @@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests var builderSecondary = new ConnectionBuilder(); builderSecondary.UseHttpServer(serviceContextSecondary, new DummyApplication(c => c.Response.WriteAsync("Secondary")), HttpProtocols.Http1); var transportContextSecondary = new TestLibuvTransportContext(); - transportContextSecondary.ConnectionHandler = new ConnectionHandler(serviceContextSecondary, builderSecondary.Build()); + transportContextSecondary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextSecondary, builderSecondary.Build()); var libuvTransport = new LibuvTransport(libuv, transportContextPrimary, listenOptions); diff --git a/test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionHandler.cs b/test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionDispatcher.cs similarity index 89% rename from test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionHandler.cs rename to test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionDispatcher.cs index edae9162f5..e4f17bbda4 100644 --- a/test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionHandler.cs +++ b/test/Kestrel.Transport.Libuv.Tests/TestHelpers/MockConnectionDispatcher.cs @@ -5,13 +5,13 @@ using System; using System.Buffers; using System.IO.Pipelines; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Protocols; -using Microsoft.AspNetCore.Protocols.Features; +using Microsoft.AspNetCore.Connections; +using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers { - public class MockConnectionHandler : IConnectionHandler + public class MockConnectionDispatcher : IConnectionDispatcher { public Func, PipeOptions> InputOptions { get; set; } = pool => new PipeOptions(pool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); public Func, PipeOptions> OutputOptions { get; set; } = pool => new PipeOptions(pool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); diff --git a/test/Kestrel.Transport.Libuv.Tests/TestHelpers/TestLibuvTransportContext.cs b/test/Kestrel.Transport.Libuv.Tests/TestHelpers/TestLibuvTransportContext.cs index d764eaf940..c779b87647 100644 --- a/test/Kestrel.Transport.Libuv.Tests/TestHelpers/TestLibuvTransportContext.cs +++ b/test/Kestrel.Transport.Libuv.Tests/TestHelpers/TestLibuvTransportContext.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers var logger = new TestApplicationErrorLogger(); AppLifetime = new LifetimeNotImplemented(); - ConnectionHandler = new MockConnectionHandler(); + ConnectionDispatcher = new MockConnectionDispatcher(); Log = new LibuvTrace(logger); Options = new LibuvTransportOptions { ThreadCount = 1 }; }