htils 1
A small set of utilities for C programming.
Loading...
Searching...
No Matches
cookie.h File Reference
#include <h2o/memory.h>
#include <h2otils/string.h>
#include <htils/basictypes.h>

Go to the source code of this file.

Data Structures

struct  h2o_cookie
 

Typedefs

typedef enum h2o_same_site_args h2o_same_site_args_t
 
typedef struct h2o_cookie h2o_cookie_t
 
typedef enum h2o_cookie_param h2o_cookie_param_t
 

Enumerations

enum  h2o_same_site_args { INVALID = -1 , NONE = 0 , LAX = 1 , STRICT = 2 }
 
enum  h2o_cookie_param {
  SAME_SITE , HTTP_ONLY , PATH , EXPIRES ,
  MAX_AGE , DOMAIN , SECURE
}
 

Functions

h2o_cookie_th2o_cookie_new (h2o_mem_pool_t *pool, const h2o_string *name, const h2o_string *value)
 Creates a new cookie with values.
 
h2o_cookie_th2o_cookie_from_string (h2o_mem_pool_t *pool, const h2o_string *str)
 Creates a new cookie from a string.
 
h2o_stringh2o_cookie_to_string (h2o_mem_pool_t *pool, h2o_cookie_t *cookie)
 Converts a cookie to a h2o_string.
 
void h2o_cookie_add_param (h2o_mem_pool_t *pool, h2o_cookie_t *cookie, h2o_cookie_param_t param, void *val)
 Adds a parameter to the cookie.
 

Typedef Documentation

◆ h2o_cookie_param_t

◆ h2o_cookie_t

typedef struct h2o_cookie h2o_cookie_t

◆ h2o_same_site_args_t

Enumeration Type Documentation

◆ h2o_cookie_param

Enumerator
SAME_SITE 
HTTP_ONLY 
PATH 
EXPIRES 
MAX_AGE 
DOMAIN 
SECURE 

◆ h2o_same_site_args

Enumerator
INVALID 
NONE 
LAX 
STRICT 

Function Documentation

◆ h2o_cookie_add_param()

void h2o_cookie_add_param ( h2o_mem_pool_t *  pool,
h2o_cookie_t cookie,
h2o_cookie_param_t  param,
void *  val 
)

Adds a parameter to the cookie.

Checks the parameter, and appends the modifier according to Set-Cookie syntax.

Parameters
poolThe memory pool to allocate the cookie from.
cookieThe cookie to add the parameter to.
paramThe parameter to add.
valThe value of the parameter, if the value is not a pointer, simply get its memory address through &.
Precondition
  • pool, cookie, and val must be valid and cannot be null.
  • param must be a valid parameter.

◆ h2o_cookie_from_string()

h2o_cookie_t * h2o_cookie_from_string ( h2o_mem_pool_t *  pool,
const h2o_string str 
)

Creates a new cookie from a string.

Parses the string and creates a new cookie from it.

Parameters
poolThe memory pool to allocate the cookie from.
strThe string to parse.
Precondition
pool and str must be valid and cannot be null.
Returns
A pointer to the new cookie.

◆ h2o_cookie_new()

h2o_cookie_t * h2o_cookie_new ( h2o_mem_pool_t *  pool,
const h2o_string name,
const h2o_string value 
)

Creates a new cookie with values.

Allocates a new cookie with the given values to conform to the Set-Cookie syntax.

Parameters
poolThe memory pool to allocate the cookie from.
nameThe name of the cookie.
valueThe value of the cookie.
Precondition
pool, name, and value must be valid and cannot be null.

◆ h2o_cookie_to_string()

h2o_string * h2o_cookie_to_string ( h2o_mem_pool_t *  pool,
h2o_cookie_t cookie 
)

Converts a cookie to a h2o_string.

Converts the cookie to a h2o_string, according to the Set-Cookie syntax.

Parameters
poolThe memory pool to allocate the string from.
cookieThe cookie to convert.
Precondition
pool and cookie must be valid and cannot be null.
Returns
A pointer to the new h2o_string.