diff options
author | vnugent <public@vaughnnugent.com> | 2023-03-09 01:48:28 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-03-09 01:48:28 -0500 |
commit | 5ddef0fcb742e77b99a0e17015d2eea0a1d4131a (patch) | |
tree | c1c88284b11b70d9f373215d8d54e8a168cc5700 /lib/Plugins.Essentials/src/Extensions | |
parent | dab71d5597fdfbe71f6ac310a240835716e952a5 (diff) |
Omega cache, session, and account provider complete overhaul
Diffstat (limited to 'lib/Plugins.Essentials/src/Extensions')
-rw-r--r-- | lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs | 12 | ||||
-rw-r--r-- | lib/Plugins.Essentials/src/Extensions/HttpCookie.cs | 26 |
2 files changed, 30 insertions, 8 deletions
diff --git a/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs b/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs index 4fd77a6..4179f74 100644 --- a/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs +++ b/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2023 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials @@ -322,10 +322,10 @@ namespace VNLib.Plugins.Essentials.Extensions /// <exception cref="InvalidOperationException"></exception> /// <exception cref="ContentTypeUnacceptableException"></exception> [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void CloseResponse(this IHttpEvent ev, HttpStatusCode code, ContentType type, in ReadOnlySpan<char> data) + public static void CloseResponse(this IHttpEvent ev, HttpStatusCode code, ContentType type, ReadOnlySpan<char> data) { //Get a memory stream using UTF8 encoding - CloseResponse(ev, code, type, in data, ev.Server.Encoding); + CloseResponse(ev, code, type, data, ev.Server.Encoding); } /// <summary> @@ -338,7 +338,7 @@ namespace VNLib.Plugins.Essentials.Extensions /// <param name="encoding">The encoding type to use when converting the buffer</param> /// <remarks>This method will store an encoded copy as a memory stream, so be careful with large buffers</remarks> [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void CloseResponse(this IHttpEvent ev, HttpStatusCode code, ContentType type, in ReadOnlySpan<char> data, Encoding encoding) + public static void CloseResponse(this IHttpEvent ev, HttpStatusCode code, ContentType type, ReadOnlySpan<char> data, Encoding encoding) { if (data.IsEmpty) { @@ -479,7 +479,7 @@ namespace VNLib.Plugins.Essentials.Extensions try { //Deserialize and return the object - obj = value.AsJsonObject<T>(options); + obj = JsonSerializer.Deserialize<T>(value, options); return true; } catch(JsonException je) @@ -543,7 +543,7 @@ namespace VNLib.Plugins.Essentials.Extensions try { //Beware this will buffer the entire file object before it attmepts to de-serialize it - return VnEncoding.JSONDeserializeFromBinary<T>(file.FileData, options); + return JsonSerializer.Deserialize<T>(file.FileData, options); } catch (JsonException je) { diff --git a/lib/Plugins.Essentials/src/Extensions/HttpCookie.cs b/lib/Plugins.Essentials/src/Extensions/HttpCookie.cs index d7f73a3..332e3d6 100644 --- a/lib/Plugins.Essentials/src/Extensions/HttpCookie.cs +++ b/lib/Plugins.Essentials/src/Extensions/HttpCookie.cs @@ -37,11 +37,33 @@ namespace VNLib.Plugins.Essentials.Extensions /// <param name="Value">The cookie value</param> public readonly record struct HttpCookie (string Name, string Value) { + /// <summary> + /// The length of time the cookie is valid for + /// </summary> public readonly TimeSpan ValidFor { get; init; } = TimeSpan.MaxValue; - public readonly string Domain { get; init; } = ""; - public readonly string Path { get; init; } = "/"; + /// <summary> + /// The cookie's domain parameter. If null, is not set in the + /// Set-Cookie header. + /// </summary> + public readonly string? Domain { get; init; } = null; + /// <summary> + /// The cookies path parameter. If null, is not + /// set in the Set-Cookie header. + /// </summary> + public readonly string? Path { get; init; } = "/"; + /// <summary> + /// The cookie's same-site parameter. Default is <see cref="CookieSameSite.None"/> + /// </summary> public readonly CookieSameSite SameSite { get; init; } = CookieSameSite.None; + /// <summary> + /// Sets the cookie's HttpOnly parameter. Default is false. When false, does not + /// set the HttpOnly paramter in the Set-Cookie header. + /// </summary> public readonly bool HttpOnly { get; init; } = false; + /// <summary> + /// Sets the cookie's Secure parameter. Default is false. When false, does not + /// set the Secure parameter in the Set-Cookie header. + /// </summary> public readonly bool Secure { get; init; } = false; /// <summary> |