HttpServerBoxed 0.0.11 alpha
A simple http server for C# and .NET
Loading...
Searching...
No Matches
HSB.Cookie Class Reference

Public Types

enum  CookiePriority { LOW , MEDIUM , HIGH }
 
enum  SameSite { Lax , Strict , None }
 

Public Member Functions

 Cookie (string name, string value)
 
 Cookie (string name, string value, DateTime? expires, string? path, CookiePriority? priority)
 
 Cookie (string cookieContent)
 
override string ToString ()
 

Public Attributes

string name
 
string value
 
DateTime? expiration
 
string? path
 
CookiePriority? priority
 
bool? secure
 
bool? HttpOnly
 
SameSite? sameSite
 

Detailed Description

Definition at line 7 of file Cookie.cs.

Member Enumeration Documentation

◆ CookiePriority

enum HSB.Cookie.CookiePriority

Definition at line 9 of file Cookie.cs.

9{ LOW, MEDIUM, HIGH };

◆ SameSite

enum HSB.Cookie.SameSite

Definition at line 10 of file Cookie.cs.

10{ Lax, Strict, None };

Constructor & Destructor Documentation

◆ Cookie() [1/4]

HSB.Cookie.Cookie ( )

Definition at line 20 of file Cookie.cs.

21 {
22 name = "";
23 value = "";
24 expiration = null;
25 path = null;
26 priority = null;
27 }

◆ Cookie() [2/4]

HSB.Cookie.Cookie ( string  name,
string  value 
)

Definition at line 29 of file Cookie.cs.

30 {
31 this.name = name;
32 this.value = value;
33 }

◆ Cookie() [3/4]

HSB.Cookie.Cookie ( string  name,
string  value,
DateTime?  expires,
string?  path,
CookiePriority?  priority 
)

Definition at line 35 of file Cookie.cs.

36 {
37 this.name = name;
38 this.value = value;
39 expiration = expires;
40 this.path = path;
41 this.priority = priority;
42 }

◆ Cookie() [4/4]

HSB.Cookie.Cookie ( string  cookieContent)

Definition at line 44 of file Cookie.cs.

45 {
46 var s = cookieContent.Split("=");
47 name = s[0];
48 value = s[1];
49 }

Member Function Documentation

◆ ToString()

override string HSB.Cookie.ToString ( )

Definition at line 51 of file Cookie.cs.

52 {
53 if (name == "" && value == "")
54 {
56 }
57
58 string cookie = $"{name}={value}";
59
60 if (expiration.HasValue)
61 {
62 cookie += $"; Expires={expiration.Value:ddd, dd MMM yyyy HH:mm:ss 'GMT'}";
63 }
64
65 if (path != null)
66 cookie += $"; Path={path}";
67
68 if (priority.HasValue)
69 cookie += $"; Priority={PriorityToString(priority.Value)}";
70
71 if (secure != null)
72 cookie += "; Secure";
73
74 if (HttpOnly != null)
75 cookie += "; HttpOnly";
76
77 if (sameSite.HasValue)
78 cookie += $"; SameSite={SameSiteToString(sameSite.Value)}";
79
80 return cookie;
81 }

Member Data Documentation

◆ expiration

DateTime? HSB.Cookie.expiration

Definition at line 13 of file Cookie.cs.

◆ HttpOnly

bool? HSB.Cookie.HttpOnly

Definition at line 17 of file Cookie.cs.

◆ name

string HSB.Cookie.name

Definition at line 11 of file Cookie.cs.

◆ path

string? HSB.Cookie.path

Definition at line 14 of file Cookie.cs.

◆ priority

CookiePriority? HSB.Cookie.priority

Definition at line 15 of file Cookie.cs.

◆ sameSite

SameSite? HSB.Cookie.sameSite

Definition at line 18 of file Cookie.cs.

◆ secure

bool? HSB.Cookie.secure

Definition at line 16 of file Cookie.cs.

◆ value

string HSB.Cookie.value

Definition at line 12 of file Cookie.cs.


The documentation for this class was generated from the following file: