Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::internal::cookie Struct Reference

Represents an HTTP cookie. More...

#include <http_types.h>

Collaboration diagram for kcenon::network::internal::cookie:
Collaboration graph

Public Member Functions

auto to_header_value () const -> std::string
 Convert cookie to Set-Cookie header value.
 

Public Attributes

std::string name
 
std::string value
 
std::string path
 
std::string domain
 
std::string expires
 
int max_age = -1
 
bool secure = false
 
bool http_only = false
 
std::string same_site
 

Detailed Description

Represents an HTTP cookie.

Structure

  • name: Cookie name
  • value: Cookie value
  • path: Path scope for the cookie
  • domain: Domain scope for the cookie
  • expires: Expiration date (HTTP date format)
  • max_age: Maximum age in seconds (-1 = session cookie)
  • secure: Secure flag (HTTPS only)
  • http_only: HttpOnly flag (not accessible via JavaScript)
  • same_site: SameSite attribute ("Strict", "Lax", "None")

Definition at line 62 of file http_types.h.

Member Function Documentation

◆ to_header_value()

auto kcenon::network::internal::cookie::to_header_value ( ) const -> std::string

Convert cookie to Set-Cookie header value.

Returns
Cookie as Set-Cookie header string

Definition at line 237 of file http_types.cpp.

238 {
239 std::string result = name + "=" + value;
240
241 if (!path.empty()) {
242 result += "; Path=" + path;
243 }
244 if (!domain.empty()) {
245 result += "; Domain=" + domain;
246 }
247 if (!expires.empty()) {
248 result += "; Expires=" + expires;
249 }
250 if (max_age >= 0) {
251 result += "; Max-Age=" + std::to_string(max_age);
252 }
253 if (http_only) {
254 result += "; HttpOnly";
255 }
256 if (secure) {
257 result += "; Secure";
258 }
259 if (!same_site.empty()) {
260 result += "; SameSite=" + same_site;
261 }
262
263 return result;
264 }

References domain, expires, http_only, max_age, name, path, same_site, secure, and value.

Referenced by kcenon::network::internal::http_parser::serialize_chunked_response(), and kcenon::network::internal::http_parser::serialize_response().

Here is the caller graph for this function:

Member Data Documentation

◆ domain

std::string kcenon::network::internal::cookie::domain

Definition at line 67 of file http_types.h.

Referenced by to_header_value().

◆ expires

std::string kcenon::network::internal::cookie::expires

Definition at line 68 of file http_types.h.

Referenced by to_header_value().

◆ http_only

bool kcenon::network::internal::cookie::http_only = false

◆ max_age

int kcenon::network::internal::cookie::max_age = -1

◆ name

std::string kcenon::network::internal::cookie::name

◆ path

std::string kcenon::network::internal::cookie::path

◆ same_site

std::string kcenon::network::internal::cookie::same_site

◆ secure

bool kcenon::network::internal::cookie::secure = false

◆ value

std::string kcenon::network::internal::cookie::value

The documentation for this struct was generated from the following files: