diff --git a/API/GenHTTP.Api.csproj b/API/GenHTTP.Api.csproj
index f6a0d771e..7c69508b5 100644
--- a/API/GenHTTP.Api.csproj
+++ b/API/GenHTTP.Api.csproj
@@ -6,9 +6,6 @@
GenHTTP HTTP Embedded Webserver Website Server Library C# Standard API
README.md
-
- CS1591,CS1587,CS1572,CS1573,CS0612,CS0618
-
diff --git a/API/Protocol/Connection.cs b/API/Protocol/Connection.cs
index 92a0a2dfb..7720ae14b 100644
--- a/API/Protocol/Connection.cs
+++ b/API/Protocol/Connection.cs
@@ -18,13 +18,6 @@ public enum Connection
/// the configured response and will close the connection after the response content
/// has been sent.
///
- Upgrade,
-
- ///
- /// The connection is surrendered to the user logic and the server will not attempt
- /// to close or change it in any way.
- ///
- [Obsolete("Required to allow Fleck to write their own response. Will be removed in GenHTTP 11.")]
- UpgradeAndSurrender
+ Upgrade
}
diff --git a/API/Protocol/IRequest.cs b/API/Protocol/IRequest.cs
index 5a1aed67a..3a4d05842 100644
--- a/API/Protocol/IRequest.cs
+++ b/API/Protocol/IRequest.cs
@@ -30,18 +30,6 @@ public interface IRequest : IDisposable
/// The newly created response
IResponseBuilder Respond();
- ///
- /// Upgrades the connection of the client, causing the underlying socket and streams
- /// to be exposed and to be used by another protocol, such as a websocket handler.
- ///
- /// The upgrade information to use
- ///
- /// After upgrading a connection, the server will surrender this socket and stream to your logic
- /// to no further interaction is done by the framework with the client and is up to
- /// your logic.
- ///
- UpgradeInfo Upgrade();
-
#endregion
#region General Infrastructure
diff --git a/API/Protocol/IResponse.cs b/API/Protocol/IResponse.cs
index 40e1e2173..1e5f5fdca 100644
--- a/API/Protocol/IResponse.cs
+++ b/API/Protocol/IResponse.cs
@@ -18,12 +18,6 @@ public interface IResponse : IDisposable
///
Connection Connection { get; set; }
- ///
- /// Specifies whether the server should surrender the connection to the user code.
- ///
- [Obsolete("Replaced by ConnectionHandling.Upgrade. This property will be removed in GenHTTP 11.")]
- public bool Upgraded { get; }
-
#endregion
#region Headers
diff --git a/API/Protocol/UpgradeInfo.cs b/API/Protocol/UpgradeInfo.cs
deleted file mode 100644
index 6d21c76a1..000000000
--- a/API/Protocol/UpgradeInfo.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System.Net.Sockets;
-
-namespace GenHTTP.Api.Protocol;
-
-///
-/// Returned when upgrading a connection.
-///
-/// The raw socket the current client is connected to
-/// The underlying network stream used for the connection (already authenticated in case of TLS)
-/// The response to return so that the server will ignore the connection further on
-[Obsolete("Set Connection(Upgrade) instead and handle the stream within the response content. Will be removed in GenHTTP 11.")]
-public record UpgradeInfo(Socket Socket, Stream Stream, IResponse Response);
diff --git a/Adapters/AspNetCore/GenHTTP.Adapters.AspNetCore.csproj b/Adapters/AspNetCore/GenHTTP.Adapters.AspNetCore.csproj
index 18cf015f1..2b878a728 100644
--- a/Adapters/AspNetCore/GenHTTP.Adapters.AspNetCore.csproj
+++ b/Adapters/AspNetCore/GenHTTP.Adapters.AspNetCore.csproj
@@ -8,9 +8,6 @@
Andreas Nägeli, Tanzim Hossain Romel
-
- CS1591,CS1587,CS1572,CS1573,CS0612,CS0618
-
diff --git a/Adapters/AspNetCore/Types/Request.cs b/Adapters/AspNetCore/Types/Request.cs
index bb8c0b153..8acd5faf7 100644
--- a/Adapters/AspNetCore/Types/Request.cs
+++ b/Adapters/AspNetCore/Types/Request.cs
@@ -102,8 +102,6 @@ public IResponseBuilder Respond()
return _responseBuilder;
}
- public UpgradeInfo Upgrade() => throw new NotSupportedException("Web sockets are not supported by the Kestrel server implementation");
-
internal void Configure(IServer server, HttpContext context)
{
var request = context.Request;
diff --git a/Directory.Build.props b/Directory.Build.props
index ae573d59d..527e8ef2e 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,9 +9,9 @@
true
enable
- 10.5.0.0
- 10.5.0.0
- 10.5.0
+ 11.0.0.0
+ 11.0.0.0
+ 11.0.0
Andreas Nägeli
diff --git a/Engine/Internal/GenHTTP.Engine.Internal.csproj b/Engine/Internal/GenHTTP.Engine.Internal.csproj
index c3dc1c388..30c6b0e6b 100644
--- a/Engine/Internal/GenHTTP.Engine.Internal.csproj
+++ b/Engine/Internal/GenHTTP.Engine.Internal.csproj
@@ -6,9 +6,6 @@
GenHTTP HTTP Embedded Webserver Server Library C# Standard Engine
README.md
-
- CS1591,CS1587,CS1572,CS1573,CS0612,CS0618
-
diff --git a/Engine/Internal/Protocol/ClientHandler.cs b/Engine/Internal/Protocol/ClientHandler.cs
index f81d58586..d402db128 100644
--- a/Engine/Internal/Protocol/ClientHandler.cs
+++ b/Engine/Internal/Protocol/ClientHandler.cs
@@ -2,13 +2,17 @@
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.Internal.Utilities;
using GenHTTP.Engine.Shared.Infrastructure;
using GenHTTP.Engine.Shared.Types;
+
using Microsoft.Extensions.ObjectPool;
+
using StringContent = GenHTTP.Modules.IO.Strings.StringContent;
namespace GenHTTP.Engine.Internal.Protocol;
@@ -68,11 +72,9 @@ internal ClientHandler(Socket socket, PoolBufferedStream stream, X509Certificate
internal async ValueTask Run()
{
- var status = Api.Protocol.Connection.Close;
-
try
{
- status = await HandlePipe(PipeReader.Create(Stream, ReaderOptions)).ConfigureAwait(false);
+ await HandlePipe(PipeReader.Create(Stream, ReaderOptions)).ConfigureAwait(false);
}
catch (Exception e)
{
@@ -80,34 +82,31 @@ internal async ValueTask Run()
}
finally
{
- if (status != Api.Protocol.Connection.UpgradeAndSurrender)
+ try
{
- try
- {
- await Stream.DisposeAsync();
- }
- catch (Exception e)
- {
- Server.Companion?.OnServerError(ServerErrorScope.ClientConnection, Connection.GetAddress(), e);
- }
+ await Stream.DisposeAsync();
+ }
+ catch (Exception e)
+ {
+ Server.Companion?.OnServerError(ServerErrorScope.ClientConnection, Connection.GetAddress(), e);
+ }
- try
- {
- Connection.Shutdown(SocketShutdown.Both);
- await Connection.DisconnectAsync(false);
- Connection.Close();
+ try
+ {
+ Connection.Shutdown(SocketShutdown.Both);
+ await Connection.DisconnectAsync(false);
+ Connection.Close();
- Connection.Dispose();
- }
- catch (Exception e)
- {
- Server.Companion?.OnServerError(ServerErrorScope.ClientConnection, Connection.GetAddress(), e);
- }
+ Connection.Dispose();
+ }
+ catch (Exception e)
+ {
+ Server.Companion?.OnServerError(ServerErrorScope.ClientConnection, Connection.GetAddress(), e);
}
}
}
- private async ValueTask HandlePipe(PipeReader reader)
+ private async ValueTask HandlePipe(PipeReader reader)
{
var context = ContextPool.Get();
@@ -139,9 +138,9 @@ private async ValueTask HandlePipe(PipeReader reader)
var status = await HandleRequest(context.Request, !buffer.ReadRequired);
- if (status is Api.Protocol.Connection.Close or Api.Protocol.Connection.UpgradeAndSurrender)
+ if (status is Api.Protocol.Connection.Close)
{
- return status;
+ return;
}
}
}
@@ -164,23 +163,16 @@ private async ValueTask HandlePipe(PipeReader reader)
await reader.CompleteAsync();
}
-
- return Api.Protocol.Connection.Close;
}
private async ValueTask HandleRequest(Request request, bool dataRemaining)
{
- request.SetConnection(Server, Connection, Stream, EndPoint, Connection.GetAddress(), ClientCertificate);
+ request.SetConnection(Server, EndPoint, Connection.GetAddress(), ClientCertificate);
var keepAliveRequested = request["Connection"]?.Equals("Keep-Alive", StringComparison.InvariantCultureIgnoreCase) ?? request.ProtocolType == HttpProtocol.Http11;
var response = await Server.Handler.HandleAsync(request) ?? throw new InvalidOperationException("The root request handler did not return a response");
- if (response.Connection == Api.Protocol.Connection.UpgradeAndSurrender)
- {
- return Api.Protocol.Connection.UpgradeAndSurrender;
- }
-
var closeRequested = response.Connection is Api.Protocol.Connection.Close or Api.Protocol.Connection.Upgrade;
var active = await ResponseHandler.Handle(request, response, request.ProtocolType, keepAliveRequested && !closeRequested, dataRemaining);
diff --git a/Engine/Internal/Protocol/Request.cs b/Engine/Internal/Protocol/Request.cs
index c2cf93881..9af7d5b69 100644
--- a/Engine/Internal/Protocol/Request.cs
+++ b/Engine/Internal/Protocol/Request.cs
@@ -1,12 +1,9 @@
using System.Net;
-using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
using GenHTTP.Api.Infrastructure;
using GenHTTP.Api.Protocol;
using GenHTTP.Api.Routing;
-
-using GenHTTP.Engine.Internal.Utilities;
using GenHTTP.Engine.Shared.Types;
using CookieCollection = GenHTTP.Engine.Shared.Types.CookieCollection;
@@ -28,9 +25,6 @@ internal sealed class Request : IRequest
private IClientConnection? _clientConnection;
private IClientConnection? _localClient;
- private Socket? _socket;
- private Stream? _stream;
-
private FlexibleRequestMethod? _method;
private RoutingTarget? _target;
@@ -130,27 +124,15 @@ public IResponseBuilder Respond()
return _responseBuilder;
}
- public UpgradeInfo Upgrade()
- {
- if (_socket == null || _stream == null)
- {
- throw new InvalidOperationException("Request is not initialized yet");
- }
-
- return new(_socket, _stream, new Response { Connection = Connection.UpgradeAndSurrender});
- }
-
public bool ContainsMultipleHeaders(string key) => _headers.ContainsMultiple(key);
#endregion
#region Parsing
- internal void SetConnection(IServer server, Socket connection, PoolBufferedStream stream, IEndPoint endPoint, IPAddress? address, X509Certificate? clientCertificate)
+ internal void SetConnection(IServer server, IEndPoint endPoint, IPAddress? address, X509Certificate? clientCertificate)
{
_server = server;
- _socket = connection;
- _stream = stream;
_endPoint = endPoint;
var protocol = _endPoint.Secure ? ClientProtocol.Https : ClientProtocol.Http;
diff --git a/Engine/Shared/GenHTTP.Engine.Shared.csproj b/Engine/Shared/GenHTTP.Engine.Shared.csproj
index 91b14122e..2a025ecf8 100644
--- a/Engine/Shared/GenHTTP.Engine.Shared.csproj
+++ b/Engine/Shared/GenHTTP.Engine.Shared.csproj
@@ -6,9 +6,6 @@
GenHTTP Engine
README.md
-
- CS1591,CS1587,CS1572,CS1573,CS0612,CS0618
-
diff --git a/Engine/Shared/Types/Response.cs b/Engine/Shared/Types/Response.cs
index 2664192f7..5a101e962 100644
--- a/Engine/Shared/Types/Response.cs
+++ b/Engine/Shared/Types/Response.cs
@@ -28,8 +28,6 @@ public Response()
public Connection Connection { get; set; }
- public bool Upgraded => Connection == Connection.UpgradeAndSurrender;
-
public DateTime? Expires { get; set; }
public DateTime? Modified { get; set; }
diff --git a/Modules/Compression/GenHTTP.Modules.Compression.csproj b/Modules/Compression/GenHTTP.Modules.Compression.csproj
index f2a27b692..c77a59a00 100644
--- a/Modules/Compression/GenHTTP.Modules.Compression.csproj
+++ b/Modules/Compression/GenHTTP.Modules.Compression.csproj
@@ -8,9 +8,6 @@
GenHTTP HTTP Webserver C# Module Compression Brotli Gzip
README.md
-
- CS1591,CS1587,CS1572,CS1573,CS0612,CS0618
-
diff --git a/Modules/Compression/Providers/WrappedRequest.cs b/Modules/Compression/Providers/WrappedRequest.cs
index 9bac17024..7b5e0e079 100644
--- a/Modules/Compression/Providers/WrappedRequest.cs
+++ b/Modules/Compression/Providers/WrappedRequest.cs
@@ -71,8 +71,6 @@ public WrappedRequest(IRequest inner, Stream decompressedContent)
public IResponseBuilder Respond() => _inner.Respond();
- public UpgradeInfo Upgrade() => _inner.Upgrade();
-
public void Dispose()
{
_decompressedContent.Dispose();
diff --git a/Modules/IO/Tracking/ChangeTrackingResource.cs b/Modules/IO/Tracking/ChangeTrackingResource.cs
index 23f53a903..4f0dbf088 100644
--- a/Modules/IO/Tracking/ChangeTrackingResource.cs
+++ b/Modules/IO/Tracking/ChangeTrackingResource.cs
@@ -56,14 +56,6 @@ public async ValueTask WriteAsync(Stream target, uint bufferSize)
/// True if the content has changed, false otherwise
public async ValueTask CheckChangedAsync() => await CalculateChecksumAsync() != _lastChecksum;
- ///
- /// True, if the content of the resource has changed
- /// since has been called
- /// the last time.
- ///
- [Obsolete("Use CheckChangedAsync() instead. This method will be removed in GenHTTP 11.")]
- public ValueTask HasChanged() => CheckChangedAsync();
-
#endregion
}
diff --git a/Modules/Inspection/Concern/InspectionConcern.cs b/Modules/Inspection/Concern/InspectionConcern.cs
index d21b2d359..7e326a609 100644
--- a/Modules/Inspection/Concern/InspectionConcern.cs
+++ b/Modules/Inspection/Concern/InspectionConcern.cs
@@ -88,7 +88,6 @@ public InspectionConcern(IHandler content, SerializationRegistry serialization)
},
Response = (content != null) ? new {
Status = content.Status.RawStatus,
- Upgraded = content.Upgraded,
Expires = content.Expires,
Modified = content.Modified,
Headers = content.Headers,
diff --git a/Modules/Inspection/GenHTTP.Modules.Inspection.csproj b/Modules/Inspection/GenHTTP.Modules.Inspection.csproj
index d20d64541..742075162 100644
--- a/Modules/Inspection/GenHTTP.Modules.Inspection.csproj
+++ b/Modules/Inspection/GenHTTP.Modules.Inspection.csproj
@@ -6,9 +6,6 @@
GenHTTP HTTP Webserver C# Module Debugging Debug Inspection Inspector
README.md
-
- CS1591,CS1587,CS1572,CS1573,CS0612,CS0618
-
diff --git a/Modules/Websockets/GenHTTP.Modules.Websockets.csproj b/Modules/Websockets/GenHTTP.Modules.Websockets.csproj
index 6f5043878..c5a523810 100644
--- a/Modules/Websockets/GenHTTP.Modules.Websockets.csproj
+++ b/Modules/Websockets/GenHTTP.Modules.Websockets.csproj
@@ -8,26 +8,22 @@
GenHTTP HTTP Webserver C# Module Websockets
README.md
-
- CS1591,CS1587,CS1572,CS1573,CS0612,CS0618
-
-
+
-
-
-
-
-
+
+
-
+
+
+
diff --git a/Modules/Websockets/IWebsocketConnection.cs b/Modules/Websockets/IWebsocketConnection.cs
deleted file mode 100644
index 5a174d358..000000000
--- a/Modules/Websockets/IWebsocketConnection.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using GenHTTP.Api.Protocol;
-
-namespace GenHTTP.Modules.Websockets;
-
-///
-/// Represents a connected websocket client.
-///
-public interface IWebsocketConnection
-{
-
- ///
- /// The original request the websocket connection was created from.
- ///
- IRequest Request { get; }
-
- ///
- /// Returns true if the socket is connected and can receive messages.
- ///
- bool IsAvailable { get; }
-
- ///
- /// Sends a text message to the connected client.
- ///
- /// The message to be sent
- Task SendAsync(string message);
-
- ///
- /// Sends a binary message to the connected client.
- ///
- /// The message to be sent
- Task SendAsync(byte[] message);
-
- ///
- /// Sends a ping message to the connected client.
- ///
- /// The message to be sent
- Task SendPingAsync(byte[] message);
-
- ///
- /// Sends a pong message to the connected client.
- ///
- /// The message to be sent
- Task SendPongAsync(byte[] message);
-
- ///
- /// Gracefully closes the connection to the client.
- ///
- void Close();
-
- ///
- /// Closes the connection with the specified code.
- ///
- /// The code to be sent to the connected client
- ///
- /// See .
- ///
- void Close(int code);
-
-}
diff --git a/Modules/Websockets/Legacy/Extensions.cs b/Modules/Websockets/Legacy/Extensions.cs
deleted file mode 100644
index a7763621b..000000000
--- a/Modules/Websockets/Legacy/Extensions.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using Fleck;
-using GenHTTP.Api.Protocol;
-
-namespace GenHTTP.Modules.Websockets.Legacy;
-
-internal static class Extensions
-{
-
- internal static WebSocketHttpRequest Map(this IRequest request)
- {
- string? body = null;
-
- if (request.Content != null)
- {
- using var reader = new StreamReader(request.Content);
-
- body = reader.ReadToEnd();
- }
-
- var mapped = new WebSocketHttpRequest
- {
- Method = request.Method.RawMethod,
- Path = request.Target.Path.ToString(true),
- Scheme = request.EndPoint.Secure ? "wss" : "ws",
- Bytes = [],
- Body = body ?? string.Empty
- };
-
- foreach (var (k, v) in request.Headers)
- {
- mapped.Headers.Add(k, v);
- }
-
- return mapped;
- }
-
-}
diff --git a/Modules/Websockets/Legacy/WebsocketConnection.cs b/Modules/Websockets/Legacy/WebsocketConnection.cs
deleted file mode 100644
index 2c9ec7aba..000000000
--- a/Modules/Websockets/Legacy/WebsocketConnection.cs
+++ /dev/null
@@ -1,261 +0,0 @@
-using Fleck;
-using GenHTTP.Api.Protocol;
-
-namespace GenHTTP.Modules.Websockets.Legacy;
-
-public sealed class WebsocketConnection : IWebSocketConnection, IWebsocketConnection
-{
- private const int ReadSize = 1024 * 4;
-
- private bool _closing;
-
- private bool _closed;
-
- private Task? _readingTask;
-
- #region Get-/Setters
-
- public ISocket Socket { get; }
-
- public IHandler? Handler { get; private set; }
-
- public IRequest Request { get; }
-
- public IWebSocketConnectionInfo? ConnectionInfo { get; private set; }
-
- public Action OnOpen { get; set; }
-
- public Action OnClose { get; set; }
-
- public Action OnMessage { get; set; }
-
- public Action OnBinary { get; set; }
-
- public Action OnPing { get; set; }
-
- public Action OnPong { get; set; }
-
- public Action OnError { get; set; }
-
- public List SupportedProtocols { get; }
-
- public bool IsAvailable => !_closing && !_closed && Socket.Connected;
-
- #endregion
-
- #region Initialization
-
- public WebsocketConnection(ISocket socket, IRequest request, List supportedProtocols,
- Func? onOpen,
- Func? onClose,
- Func? onMessage,
- Func? onBinary,
- Func? onPing,
- Func? onPong,
- Func? onError)
- {
- Socket = socket;
- Request = request;
-
- SupportedProtocols = supportedProtocols;
-
- OnOpen = (onOpen != null) ? () => WebsocketDispatcher.Schedule(() => onOpen(this)) : () => { };
- OnClose = (onClose != null) ? () => WebsocketDispatcher.Schedule(() => onClose(this)) : () => { };
- OnMessage = (onMessage != null) ? x => WebsocketDispatcher.Schedule(() => onMessage(this, x)) : x => { };
- OnBinary = (onBinary != null) ? x => WebsocketDispatcher.Schedule(() => onBinary(this, x)) : x => { };
- OnPing = (onPing != null) ? x => WebsocketDispatcher.Schedule(() => onPing(this, x)) : x => WebsocketDispatcher.Schedule(() => SendPongAsync(x));
- OnPong = (onPong != null) ? x => WebsocketDispatcher.Schedule(() => onPong(this, x)) : x => { };
- OnError = (onError != null) ? x => WebsocketDispatcher.Schedule(() => onError(this, x)) : x => { };
- }
-
- #endregion
-
- #region Functionality
-
- public Task Send(string message) => SendAsync(message);
-
- public Task Send(byte[] message) => SendAsync(message);
-
- public Task SendPing(byte[] message) => SendPingAsync(message);
-
- public Task SendPong(byte[] message) => SendPongAsync(message);
-
- public Task SendAsync(string message) => Send(message, GetHandler().FrameText);
-
- public Task SendAsync(byte[] message) => Send(message, GetHandler().FrameBinary);
-
- public Task SendPingAsync(byte[] message) => Send(message, GetHandler().FramePing);
-
- public Task SendPongAsync(byte[] message) => Send(message, GetHandler().FramePong);
-
- private Task Send(T message, Func createFrame)
- {
- if (Handler == null)
- throw new InvalidOperationException("Cannot send before handshake");
-
- if (!IsAvailable)
- {
- const string errorMessage = "Data sent while closing or after close. Ignoring.";
- FleckLog.Warn(errorMessage);
-
- var taskForException = new TaskCompletionSource