diff --git a/Engine/Internal/GenHTTP.Engine.Internal.csproj b/Engine/Internal/GenHTTP.Engine.Internal.csproj index 7d004625..5028b7f2 100644 --- a/Engine/Internal/GenHTTP.Engine.Internal.csproj +++ b/Engine/Internal/GenHTTP.Engine.Internal.csproj @@ -48,8 +48,6 @@ - - diff --git a/Engine/Internal/Infrastructure/Endpoints/EndPoint.cs b/Engine/Internal/Infrastructure/Endpoints/EndPoint.cs index abe06e0a..59f46799 100644 --- a/Engine/Internal/Infrastructure/Endpoints/EndPoint.cs +++ b/Engine/Internal/Infrastructure/Endpoints/EndPoint.cs @@ -1,10 +1,11 @@ using System.Net; using System.Net.Sockets; using System.Security.Cryptography.X509Certificates; + using GenHTTP.Api.Infrastructure; + using GenHTTP.Engine.Internal.Protocol; using GenHTTP.Engine.Shared.Infrastructure; -using PooledAwait; namespace GenHTTP.Engine.Internal.Infrastructure.Endpoints; @@ -95,9 +96,9 @@ private void Handle(Socket client) Task.Run(() => Accept(client)); } - protected abstract PooledValueTask Accept(Socket client); + protected abstract ValueTask Accept(Socket client); - protected PooledValueTask Handle(Socket client, Stream inputStream, X509Certificate? clientCertificate = null) + protected ValueTask Handle(Socket client, Stream inputStream, X509Certificate? clientCertificate = null) { client.NoDelay = true; diff --git a/Engine/Internal/Infrastructure/Endpoints/InsecureEndPoint.cs b/Engine/Internal/Infrastructure/Endpoints/InsecureEndPoint.cs index 5f189fe0..6581be2b 100644 --- a/Engine/Internal/Infrastructure/Endpoints/InsecureEndPoint.cs +++ b/Engine/Internal/Infrastructure/Endpoints/InsecureEndPoint.cs @@ -6,8 +6,6 @@ using GenHTTP.Engine.Internal.Utilities; using GenHTTP.Engine.Shared.Infrastructure; -using PooledAwait; - namespace GenHTTP.Engine.Internal.Infrastructure.Endpoints; internal sealed class InsecureEndPoint : EndPoint @@ -31,7 +29,7 @@ internal InsecureEndPoint(IServer server, IPAddress? address, ushort port, Netwo #region Functionality - protected override PooledValueTask Accept(Socket client) => Handle(client, new PoolBufferedStream(new NetworkStream(client), Configuration.TransferBufferSize)); + protected override ValueTask Accept(Socket client) => Handle(client, new PoolBufferedStream(new NetworkStream(client), Configuration.TransferBufferSize)); #endregion diff --git a/Engine/Internal/Infrastructure/Endpoints/SecureEndPoint.cs b/Engine/Internal/Infrastructure/Endpoints/SecureEndPoint.cs index c8366f6d..e51152be 100644 --- a/Engine/Internal/Infrastructure/Endpoints/SecureEndPoint.cs +++ b/Engine/Internal/Infrastructure/Endpoints/SecureEndPoint.cs @@ -9,8 +9,6 @@ using GenHTTP.Engine.Internal.Utilities; using GenHTTP.Engine.Shared.Infrastructure; -using PooledAwait; - namespace GenHTTP.Engine.Internal.Infrastructure.Endpoints; internal sealed class SecureEndPoint : EndPoint @@ -53,7 +51,7 @@ internal SecureEndPoint(IServer server, IPAddress? address, ushort port, Securit #region Functionality - protected override async PooledValueTask Accept(Socket client) + protected override async ValueTask Accept(Socket client) { var stream = await TryAuthenticate(client); diff --git a/Engine/Internal/Protocol/ClientHandler.cs b/Engine/Internal/Protocol/ClientHandler.cs index 4d0f7af0..b02411fe 100644 --- a/Engine/Internal/Protocol/ClientHandler.cs +++ b/Engine/Internal/Protocol/ClientHandler.cs @@ -2,13 +2,13 @@ using System.IO.Pipelines; using System.Net.Sockets; using System.Security.Cryptography.X509Certificates; + using GenHTTP.Api.Infrastructure; using GenHTTP.Api.Protocol; using GenHTTP.Engine.Internal.Protocol.Parser; using GenHTTP.Engine.Shared.Infrastructure; using GenHTTP.Engine.Shared.Types; -using PooledAwait; using StringContent = GenHTTP.Modules.IO.Strings.StringContent; @@ -67,7 +67,7 @@ internal ClientHandler(Socket socket, Stream stream, X509Certificate? clientCert #region Functionality - internal async PooledValueTask Run() + internal async ValueTask Run() { var status = ConnectionStatus.Close; @@ -108,7 +108,7 @@ internal async PooledValueTask Run() } } - private async PooledValueTask HandlePipe(PipeReader reader) + private async ValueTask HandlePipe(PipeReader reader) { try { @@ -151,7 +151,7 @@ private async PooledValueTask HandlePipe(PipeReader reader) return ConnectionStatus.Close; } - private async PooledValueTask HandleRequest(RequestBuilder builder, bool dataRemaining) + private async ValueTask HandleRequest(RequestBuilder builder, bool dataRemaining) { using var request = builder.Connection(Server, Connection, Stream, EndPoint, Connection.GetAddress(), ClientCertificate).Build(); @@ -171,7 +171,7 @@ private async PooledValueTask HandleRequest(RequestBuilder bui return (active && keepAlive) ? ConnectionStatus.KeepAlive : ConnectionStatus.Close; } - private async PooledValueTask SendError(Exception e, ResponseStatus status) + private async ValueTask SendError(Exception e, ResponseStatus status) { try { @@ -184,7 +184,8 @@ private async PooledValueTask SendError(Exception e, ResponseStatus status) await ResponseHandler.Handle(null, response, false, false); } catch - { /* no recovery here */ + { + /* no recovery here */ } } diff --git a/Engine/Internal/Protocol/Parser/RequestParser.cs b/Engine/Internal/Protocol/Parser/RequestParser.cs index 1d6e60b5..58a05353 100644 --- a/Engine/Internal/Protocol/Parser/RequestParser.cs +++ b/Engine/Internal/Protocol/Parser/RequestParser.cs @@ -3,8 +3,6 @@ using GenHTTP.Engine.Internal.Protocol.Parser.Conversion; using GenHTTP.Engine.Shared.Infrastructure; -using PooledAwait; - namespace GenHTTP.Engine.Internal.Protocol.Parser; /// @@ -43,7 +41,7 @@ internal RequestParser(NetworkConfiguration configuration) #region Functionality - internal async PooledValueTask TryParseAsync(RequestBuffer buffer) + internal async ValueTask TryParseAsync(RequestBuffer buffer) { if (!await Type(buffer)) { @@ -69,7 +67,7 @@ internal RequestParser(NetworkConfiguration configuration) return result; } - private async PooledValueTask Type(RequestBuffer buffer) + private async ValueTask Type(RequestBuffer buffer) { Scanner.Mode = ScannerMode.Words; @@ -78,10 +76,11 @@ private async PooledValueTask Type(RequestBuffer buffer) Request.Type(MethodConverter.ToRequestMethod(Scanner.Value)); return true; } + return false; } - private async PooledValueTask Path(RequestBuffer buffer) + private async ValueTask Path(RequestBuffer buffer) { Scanner.Mode = ScannerMode.Path; @@ -115,7 +114,7 @@ private async PooledValueTask Path(RequestBuffer buffer) } } - private async PooledValueTask Protocol(RequestBuffer buffer) + private async ValueTask Protocol(RequestBuffer buffer) { Scanner.Mode = ScannerMode.Words; @@ -125,7 +124,7 @@ private async PooledValueTask Protocol(RequestBuffer buffer) } } - private async PooledValueTask Headers(RequestBuffer buffer) + private async ValueTask Headers(RequestBuffer buffer) { Scanner.Mode = ScannerMode.HeaderKey; @@ -144,7 +143,7 @@ private async PooledValueTask Headers(RequestBuffer buffer) } } - private async PooledValueTask Body(RequestBuffer buffer) + private async ValueTask Body(RequestBuffer buffer) { if (Request.Headers.TryGetValue("Content-Length", out var bodyLength)) { diff --git a/Engine/Internal/Protocol/Parser/RequestScanner.cs b/Engine/Internal/Protocol/Parser/RequestScanner.cs index 05377af4..12bbb2a9 100644 --- a/Engine/Internal/Protocol/Parser/RequestScanner.cs +++ b/Engine/Internal/Protocol/Parser/RequestScanner.cs @@ -2,8 +2,6 @@ using GenHTTP.Api.Protocol; -using PooledAwait; - namespace GenHTTP.Engine.Internal.Protocol.Parser; internal sealed class RequestScanner @@ -21,7 +19,7 @@ internal RequestScanner() internal ScannerMode Mode { get; set; } - internal async PooledValueTask Next(RequestBuffer buffer, RequestToken expectedToken, bool allowNone = false, bool includeWhitespace = false) + internal async ValueTask Next(RequestBuffer buffer, RequestToken expectedToken, bool allowNone = false, bool includeWhitespace = false) { var read = await Next(buffer, false, includeWhitespace); @@ -38,7 +36,7 @@ internal async PooledValueTask Next(RequestBuffer buffer, RequestToken exp return true; } - internal async PooledValueTask Next(RequestBuffer buffer, bool forceRead = false, bool includeWhitespace = false) + internal async ValueTask Next(RequestBuffer buffer, bool forceRead = false, bool includeWhitespace = false) { // ensure we have data to be scanned if (await Fill(buffer, forceRead)) @@ -185,7 +183,7 @@ private bool ReadTo(RequestBuffer buffer, char delimiter, char? boundary = null, return false; } - private static async PooledValueTask Fill(RequestBuffer buffer, bool force = false) + private static async ValueTask Fill(RequestBuffer buffer, bool force = false) { if (buffer.ReadRequired || force) { @@ -194,4 +192,5 @@ private static async PooledValueTask Fill(RequestBuffer buffer, bool force return !buffer.Data.IsEmpty; } + } diff --git a/Engine/Internal/Protocol/RequestBuffer.cs b/Engine/Internal/Protocol/RequestBuffer.cs index a07d037a..252032cd 100644 --- a/Engine/Internal/Protocol/RequestBuffer.cs +++ b/Engine/Internal/Protocol/RequestBuffer.cs @@ -3,8 +3,6 @@ using GenHTTP.Engine.Shared.Infrastructure; -using PooledAwait; - namespace GenHTTP.Engine.Internal.Protocol; /// @@ -50,7 +48,7 @@ internal RequestBuffer(PipeReader reader, NetworkConfiguration configuration) #region Functionality - internal async PooledValueTask ReadAsync(bool force = false) + internal async ValueTask ReadAsync(bool force = false) { if (ReadRequired || force) { diff --git a/Modules/Caching/GenHTTP.Modules.Caching.csproj b/Modules/Caching/GenHTTP.Modules.Caching.csproj index 7910579c..0958c968 100644 --- a/Modules/Caching/GenHTTP.Modules.Caching.csproj +++ b/Modules/Caching/GenHTTP.Modules.Caching.csproj @@ -46,8 +46,6 @@ - - diff --git a/README.md b/README.md index aa93438d..c0f2cc87 100644 --- a/README.md +++ b/README.md @@ -122,5 +122,4 @@ in C#. In 2024 the focus has shifted towards API development, dropping support f ## 🙏 Thanks - Powered by [.NET](https://github.com/dotnet/core) -- Less allocations thanks to [PooledAwait](https://github.com/mgravell/PooledAwait) - Modules implemented with [NSwag](https://github.com/RicoSuter/NSwag) (Open API), [Fleck](https://github.com/statianzo/Fleck) (WebSockets)