diff --git a/src/Servers/Kestrel/Core/src/Internal/ClosedStream.cs b/src/Servers/Kestrel/Core/src/Internal/ClosedStream.cs deleted file mode 100644 index 15bd864bca25..000000000000 --- a/src/Servers/Kestrel/Core/src/Internal/ClosedStream.cs +++ /dev/null @@ -1,68 +0,0 @@ -// 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; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal -{ - internal sealed class ClosedStream : Stream - { - private static readonly Task ZeroResultTask = Task.FromResult(result: 0); - - public override bool CanRead => true; - public override bool CanSeek => false; - public override bool CanWrite => false; - - public override long Length - { - get - { - throw new NotSupportedException(); - } - } - - public override long Position - { - get - { - throw new NotSupportedException(); - } - set - { - throw new NotSupportedException(); - } - } - - public override void Flush() - { - } - - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException(); - } - - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - public override int Read(byte[] buffer, int offset, int count) - { - return 0; - } - - public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) - { - return ZeroResultTask; - } - - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException(); - } - } -} diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/PipelineExtensions.cs b/src/Servers/Kestrel/Core/src/Internal/Http/BufferExtensions.cs similarity index 98% rename from src/Servers/Kestrel/Core/src/Internal/Http/PipelineExtensions.cs rename to src/Servers/Kestrel/Core/src/Internal/Http/BufferExtensions.cs index d98768bd1dc3..f24886152b07 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/PipelineExtensions.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/BufferExtensions.cs @@ -7,9 +7,9 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http +namespace System.Buffers { - internal static class PipelineExtensions + internal static class BufferExtensions { private const int _maxULongByteLength = 20; diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/CancellationTokenExtensions.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/CancellationTokenExtensions.cs deleted file mode 100644 index c5d0392f0012..000000000000 --- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/CancellationTokenExtensions.cs +++ /dev/null @@ -1,76 +0,0 @@ -// 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; -using System.Threading; - -namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure -{ - internal static class CancellationTokenExtensions - { - public static IDisposable SafeRegister(this CancellationToken cancellationToken, Action callback, object state) - { - var callbackWrapper = new CancellationCallbackWrapper(callback, state); - var registration = cancellationToken.Register(s => InvokeCallback(s), callbackWrapper); - var disposeCancellationState = new DisposeCancellationState(callbackWrapper, registration); - - return new DisposableAction(s => Dispose(s), disposeCancellationState); - } - - private static void InvokeCallback(object state) - { - ((CancellationCallbackWrapper)state).TryInvoke(); - } - - private static void Dispose(object state) - { - ((DisposeCancellationState)state).TryDispose(); - } - - private class DisposeCancellationState - { - private readonly CancellationCallbackWrapper _callbackWrapper; - private readonly CancellationTokenRegistration _registration; - - public DisposeCancellationState(CancellationCallbackWrapper callbackWrapper, CancellationTokenRegistration registration) - { - _callbackWrapper = callbackWrapper; - _registration = registration; - } - - public void TryDispose() - { - if (_callbackWrapper.TrySetInvoked()) - { - _registration.Dispose(); - } - } - } - - private class CancellationCallbackWrapper - { - private readonly Action _callback; - private readonly object _state; - private int _callbackInvoked; - - public CancellationCallbackWrapper(Action callback, object state) - { - _callback = callback; - _state = state; - } - - public bool TrySetInvoked() - { - return Interlocked.Exchange(ref _callbackInvoked, 1) == 0; - } - - public void TryInvoke() - { - if (TrySetInvoked()) - { - _callback(_state); - } - } - } - } -} diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/DisposableAction.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/DisposableAction.cs deleted file mode 100644 index ff65931e24ee..000000000000 --- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/DisposableAction.cs +++ /dev/null @@ -1,40 +0,0 @@ -// 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; -using System.Threading; - -namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure -{ - internal class DisposableAction : IDisposable - { - public static readonly DisposableAction Empty = new DisposableAction(() => { }); - - private Action _action; - private readonly object _state; - - public DisposableAction(Action action) - : this(state => ((Action)state).Invoke(), state: action) - { - } - - public DisposableAction(Action action, object state) - { - _action = action; - _state = state; - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - Interlocked.Exchange(ref _action, (state) => { }).Invoke(_state); - } - } - - public void Dispose() - { - Dispose(true); - } - } -} diff --git a/src/Servers/Kestrel/Core/src/Internal/ConnectionLimitMiddleware.cs b/src/Servers/Kestrel/Core/src/Middleware/ConnectionLimitMiddleware.cs similarity index 100% rename from src/Servers/Kestrel/Core/src/Internal/ConnectionLimitMiddleware.cs rename to src/Servers/Kestrel/Core/src/Middleware/ConnectionLimitMiddleware.cs diff --git a/src/Servers/Kestrel/Core/src/Internal/HttpConnectionBuilderExtensions.cs b/src/Servers/Kestrel/Core/src/Middleware/HttpConnectionBuilderExtensions.cs similarity index 100% rename from src/Servers/Kestrel/Core/src/Internal/HttpConnectionBuilderExtensions.cs rename to src/Servers/Kestrel/Core/src/Middleware/HttpConnectionBuilderExtensions.cs diff --git a/src/Servers/Kestrel/Core/src/Internal/HttpConnectionMiddleware.cs b/src/Servers/Kestrel/Core/src/Middleware/HttpConnectionMiddleware.cs similarity index 100% rename from src/Servers/Kestrel/Core/src/Internal/HttpConnectionMiddleware.cs rename to src/Servers/Kestrel/Core/src/Middleware/HttpConnectionMiddleware.cs diff --git a/src/Servers/Kestrel/Core/src/Internal/HttpsConnectionMiddleware.cs b/src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs similarity index 100% rename from src/Servers/Kestrel/Core/src/Internal/HttpsConnectionMiddleware.cs rename to src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs diff --git a/src/Servers/Kestrel/Core/src/Middleware/Internal/LoggingConnectionMiddleware.cs b/src/Servers/Kestrel/Core/src/Middleware/LoggingConnectionMiddleware.cs similarity index 100% rename from src/Servers/Kestrel/Core/src/Middleware/Internal/LoggingConnectionMiddleware.cs rename to src/Servers/Kestrel/Core/src/Middleware/LoggingConnectionMiddleware.cs diff --git a/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj b/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj index fa82cf0beb3c..843f1b8e9336 100644 --- a/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj +++ b/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Servers/Kestrel/Transport.Libuv/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj b/src/Servers/Kestrel/Transport.Libuv/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj index 8e87e8ff659f..42a5a7943b1c 100644 --- a/src/Servers/Kestrel/Transport.Libuv/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj +++ b/src/Servers/Kestrel/Transport.Libuv/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj @@ -1,4 +1,4 @@ - + Libuv transport for the ASP.NET Core Kestrel cross-platform web server. @@ -12,7 +12,7 @@ - + diff --git a/src/Servers/Kestrel/Transport.Sockets/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj b/src/Servers/Kestrel/Transport.Sockets/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj index b3c3cb669a9c..09398f57ac1d 100644 --- a/src/Servers/Kestrel/Transport.Sockets/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj +++ b/src/Servers/Kestrel/Transport.Sockets/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj @@ -1,4 +1,4 @@ - + Managed socket transport for the ASP.NET Core Kestrel cross-platform web server. @@ -12,7 +12,7 @@ - + diff --git a/src/Servers/Kestrel/perf/Kestrel.Performance/Microsoft.AspNetCore.Server.Kestrel.Performance.csproj b/src/Servers/Kestrel/perf/Kestrel.Performance/Microsoft.AspNetCore.Server.Kestrel.Performance.csproj index 4ed53085bc79..0789bc504909 100644 --- a/src/Servers/Kestrel/perf/Kestrel.Performance/Microsoft.AspNetCore.Server.Kestrel.Performance.csproj +++ b/src/Servers/Kestrel/perf/Kestrel.Performance/Microsoft.AspNetCore.Server.Kestrel.Performance.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.0 @@ -15,6 +15,7 @@ + diff --git a/src/Servers/Kestrel/Core/src/Internal/DuplexPipe.cs b/src/Servers/Kestrel/shared/DuplexPipe.cs similarity index 100% rename from src/Servers/Kestrel/Core/src/Internal/DuplexPipe.cs rename to src/Servers/Kestrel/shared/DuplexPipe.cs diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj b/src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj index 9e3f73ee5f35..3e6f1bcd6ad0 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj @@ -13,6 +13,7 @@ +