From 05ebe3b38342ba38ad0f1c418058d5100ca776ab Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 21 Jan 2023 21:43:21 -0500 Subject: Fix FBM session cancel, fix plugin log file names --- .../src/Extensions/EssentialHttpEventExtensions.cs | 7 +++++++ .../src/Extensions/RedirectType.cs | 24 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'lib/Plugins.Essentials/src/Extensions') diff --git a/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs b/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs index 9458487..4fd77a6 100644 --- a/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs +++ b/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs @@ -428,9 +428,16 @@ namespace VNLib.Plugins.Essentials.Extensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Redirect(this IHttpEvent ev, RedirectType type, Uri location) { + + if(type == RedirectType.None) + { + throw new ArgumentException("Invalid redirect type of none", nameof(type)); + } + //Encode the string for propery http url formatting and set the location header ev.Server.Headers[HttpResponseHeader.Location] = location.ToString(); ev.Server.SetNoCache(); + //Set redirect the ressponse redirect code type ev.CloseResponse((HttpStatusCode)type); } diff --git a/lib/Plugins.Essentials/src/Extensions/RedirectType.cs b/lib/Plugins.Essentials/src/Extensions/RedirectType.cs index eff4d38..4c9f025 100644 --- a/lib/Plugins.Essentials/src/Extensions/RedirectType.cs +++ b/lib/Plugins.Essentials/src/Extensions/RedirectType.cs @@ -31,7 +31,29 @@ namespace VNLib.Plugins.Essentials.Extensions /// public enum RedirectType { + /// + /// NOT-USED + /// None, - Moved = 301, Found = 302, SeeOther = 303, Temporary = 307, Permanent = 308 + /// + /// Sets the HTTP 301 response code for a "moved" redirect + /// + Moved = 301, + /// + /// Sets the HTTP 302 response code for a "Found" redirect + /// + Found = 302, + /// + /// Sets the HTTP 303 response code for a "SeeOther" redirect + /// + SeeOther = 303, + /// + /// Sets the HTTP 307 response code for a "Temporary" redirect + /// + Temporary = 307, + /// + /// Sets the HTTP 308 response code for a "Permanent" redirect + /// + Permanent = 308 } } \ No newline at end of file -- cgit