diff options
Diffstat (limited to 'lib/Plugins.Essentials/src/Extensions')
-rw-r--r-- | lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs | 7 | ||||
-rw-r--r-- | lib/Plugins.Essentials/src/Extensions/RedirectType.cs | 24 |
2 files changed, 30 insertions, 1 deletions
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 /// </summary> public enum RedirectType { + /// <summary> + /// NOT-USED + /// </summary> None, - Moved = 301, Found = 302, SeeOther = 303, Temporary = 307, Permanent = 308 + /// <summary> + /// Sets the HTTP 301 response code for a "moved" redirect + /// </summary> + Moved = 301, + /// <summary> + /// Sets the HTTP 302 response code for a "Found" redirect + /// </summary> + Found = 302, + /// <summary> + /// Sets the HTTP 303 response code for a "SeeOther" redirect + /// </summary> + SeeOther = 303, + /// <summary> + /// Sets the HTTP 307 response code for a "Temporary" redirect + /// </summary> + Temporary = 307, + /// <summary> + /// Sets the HTTP 308 response code for a "Permanent" redirect + /// </summary> + Permanent = 308 } }
\ No newline at end of file |