#include <h2o/memory.h>
#include <htils/basictypes.h>
#include <h2otils/string.h>
#include <h2otils/stringmap.h>
Go to the source code of this file.
|
| h2o_cookie_t * | h2o_cookie_new (h2o_mem_pool_t *pool, const h2o_string **names, const h2o_string **values, const u64 amount) |
| | Creates a new cookie with values.
|
| |
| h2o_cookie_t * | h2o_cookie_from_string (h2o_mem_pool_t *pool, const h2o_string *str) |
| | Creates a new cookie from a string.
|
| |
| void | h2o_cookie_add_param (h2o_mem_pool_t *pool, h2o_cookie_t *cookie, h2o_cookie_param_t param,...) |
| | Adds a parameter to the cookie.
|
| |
| void | h2o_cookie_append (h2o_cookie_t *cookie, const h2o_string *key, const h2o_string *value) |
| | Appends a key-value pair to the cookie.
|
| |
| h2o_string * | h2o_cookie_to_string (h2o_mem_pool_t *pool, h2o_cookie_t *cookie) |
| | Converts a cookie to a h2o_string.
|
| |
| h2o_string * | h2o_cookie_get_value (h2o_cookie_t *cookie, const h2o_string *key) |
| | Gets a value from the cookie.
|
| |
◆ h2o_cookie_param_t
Cookie parameter types.
- Parameters
-
| SAME_SITE | The SameSite parameter. |
| HTTP_ONLY | The HttpOnly parameter. |
| PATH | The Path parameter. |
| EXPIRES | The Expires parameter. |
| MAX_AGE | The Max-Age parameter. |
| DOMAIN | The Domain parameter. |
| SECURE | The Secure parameter. |
◆ h2o_cookie_t
Cookie structure.
- Parameters
-
| names | The names of each cookie field. |
| values | The values of each cookie field. |
| domain | The domain of the cookie. |
| path | The path of the cookie. |
| expires_str | The expires string of the cookie. |
| same_site | The SameSite value of the cookie. |
| expires | The expires value of the cookie. |
| max_age | The max-age value of the cookie. |
| secure | The secure value of the cookie. |
| http_only | The http-only value of the cookie. |
◆ h2o_same_site_args_t
SameSite argument types.
- Parameters
-
| INVALID | An invalid SameSite value, for initializing only, or to mark SameSite as not being a part of the Cookie. |
| NONE | The None SameSite value. |
| LAX | The Lax SameSite value. |
| STRICT | The Strict SameSite value. |
◆ h2o_cookie_param
Cookie parameter types.
- Parameters
-
| SAME_SITE | The SameSite parameter. |
| HTTP_ONLY | The HttpOnly parameter. |
| PATH | The Path parameter. |
| EXPIRES | The Expires parameter. |
| MAX_AGE | The Max-Age parameter. |
| DOMAIN | The Domain parameter. |
| SECURE | The Secure parameter. |
| Enumerator |
|---|
| SAME_SITE | |
| HTTP_ONLY | |
| PATH | |
| EXPIRES | |
| MAX_AGE | |
| DOMAIN | |
| SECURE | |
◆ h2o_same_site_args
SameSite argument types.
- Parameters
-
| INVALID | An invalid SameSite value, for initializing only, or to mark SameSite as not being a part of the Cookie. |
| NONE | The None SameSite value. |
| LAX | The Lax SameSite value. |
| STRICT | The Strict SameSite value. |
| Enumerator |
|---|
| INVALID | |
| NONE | |
| LAX | |
| STRICT | |
◆ h2o_cookie_add_param()
Adds a parameter to the cookie.
Checks the parameter, and appends the modifier according to Set-Cookie syntax.
- Parameters
-
| pool | The memory pool to allocate the cookie from. |
| cookie | The cookie to add the parameter to. |
| param | The parameter to add. |
| ... | The value of the parameter, as provided by variadic args. |
- Precondition
pool, cookie, and val must be valid and cannot be null.
param must be a valid parameter.
◆ h2o_cookie_append()
Appends a key-value pair to the cookie.
Appends a key-value pair to the cookie, if the key already exists, its updated, otherwise it will be created.
- Parameters
-
| cookie | The cookie to append to. |
| key | The key to append. |
| value | The value to append. |
- Precondition
cookie, key, and value must be valid and cannot be null.
◆ h2o_cookie_from_string()
Creates a new cookie from a string.
Parses the string and creates a new cookie from it.
- Parameters
-
| pool | The memory pool to allocate the cookie from. |
| str | The string to parse. |
- Precondition
pool and str must be valid and cannot be null.
- Returns
- A pointer to the new cookie.
◆ h2o_cookie_get_value()
Gets a value from the cookie.
Gets a value from the cookie, if the key doesn't exist, it will return null.
- Parameters
-
| cookie | The cookie to get the value from. |
| key | The key to get the value from. |
- Precondition
cookie and key must be valid and cannot be null.
- Returns
- A pointer to the value, or null if it doesn't exist.
◆ h2o_cookie_new()
Creates a new cookie with values.
Allocates a new cookie with the given values to conform to the Set-Cookie syntax.
- Parameters
-
| pool | The memory pool to allocate the cookie from. |
| names | The names of each cookie field. |
| values | The values of each cookie field. |
| amount | The amount of cookie keys and values within the cookie. |
- Precondition
pool, names, and values must be valid and cannot be null.
◆ h2o_cookie_to_string()
Converts a cookie to a h2o_string.
Converts the cookie to a h2o_string, according to the Set-Cookie syntax.
- Parameters
-
| pool | The memory pool to allocate the string from. |
| cookie | The cookie to convert. |
- Precondition
pool and cookie must be valid and cannot be null.
- Returns
- A pointer to the new h2o_string.