The Cookie header is used to transmit state information from server back to the http client. More...
Defines | |
#define | HTTP_COOKIE_INIT() |
Initializer for structure http_cookie_t. | |
#define | HTTPTAG_COOKIE(x) |
Tag list item for pointer to a Cookie header object. | |
#define | HTTPTAG_COOKIE_STR(s) |
Tag list item for string with Cookie header value. | |
Typedefs | |
typedef struct http_cookie_s | http_cookie_t |
The structure http_cookie_t contains representation of Cookie header. | |
Enumerations | |
enum | { http_cookie_hash } |
Functions | |
http_cookie_t * | http_cookie_init (http_cookie_t x[1]) |
Initialize a structure http_cookie_t. | |
int | http_is_cookie (http_header_t const *header) |
Test if header object is instance of http_cookie_t. | |
http_cookie_t * | http_cookie_dup (su_home_t *home, http_cookie_t const *hdr)) |
Duplicate (deep copy) http_cookie_t . | |
http_cookie_t * | http_cookie_copy (su_home_t *home, http_cookie_t const *hdr)) |
Copy a http_cookie_t header structure. | |
http_cookie_t * | http_cookie_make (su_home_t *home, char const *s)) |
Make a header structure http_cookie_t. | |
http_cookie_t * | http_cookie_format (su_home_t *home, char const *fmt,...))) |
Make a Cookie header from formatting result. | |
Variables | |
msg_hclass_t | http_cookie_class [] |
Header class for HTTP Cookie header. | |
msg_parse_f | http_cookie_d |
Decode (parse) a Cookie header. | |
msg_print_f | http_cookie_e |
Encode (print) a Cookie header. |
The Cookie header is used to transmit state information from server back to the http client.
Its syntax is defined in RFC 2109 section 4.3.4 as follows:
cookie = "Cookie:" cookie-version 1*((";" | ",") cookie-value) cookie-value = NAME "=" VALUE [";" path] [";" domain] cookie-version = "$Version" "=" value NAME = attr VALUE = value path = "$Path" "=" value domain = "$Domain" "=" value
#define HTTP_COOKIE_INIT | ( | ) |
Initializer for structure http_cookie_t.
A static http_cookie_t structure must be initialized with the HTTP_COOKIE_INIT() macro. For instance,
http_cookie_t http_cookie = HTTP_COOKIE_INIT;
#define HTTPTAG_COOKIE | ( | x | ) |
Tag list item for pointer to a Cookie header object.
The HTTPTAG_COOKIE() macro is used to include a tag item with a pointer to a http_cookie_t object in a tag list.
x | pointer to a http_cookie_t header structure, or NULL. |
#define HTTPTAG_COOKIE_STR | ( | s | ) |
Tag list item for string with Cookie header value.
The HTTPTAG_COOKIE_STR() macro is used to include a tag item with a string containing value of a http_cookie_t header in a tag list.
s | pointer to a string containing http_cookie_t value, or NULL. |
The HTTPTAG_COOKIE_STR string can be converted to a http_cookie_t header structure by giving the string s has second argument to function http_cookie_make().
typedef struct http_cookie_s http_cookie_t |
The structure http_cookie_t contains representation of Cookie header.
Please note that a single http_cookie_t can contain many cookies.
The http_cookie_t is defined as follows:
typedef struct http_cookie_s { } http_cookie_t;
http_cookie_t * http_cookie_copy | ( | su_home_t * | home, | |
http_cookie_t const * | hdr | |||
) | [inline] |
Copy a http_cookie_t header structure.
The function http_cookie_copy() copies a header structure hdr. If the header structure hdr contains a reference (hdr->h_next
) to a list of headers, all the headers in that list are copied, too. The function uses given memory home to allocate all the memory areas used to copy the header structure hdr.
home | memory home used to allocate new structure | |
hdr | pointer to the header structure to be duplicated |
When copying, only the header structure and parameter lists attached to it are duplicated. The new header structure retains all the references to the strings within the old header, including the encoding of the old header, if present.
cookie = http_cookie_copy(home, http->http_cookie);
http_cookie_t * http_cookie_dup | ( | su_home_t * | home, | |
http_cookie_t const * | hdr | |||
) | [inline] |
Duplicate (deep copy) http_cookie_t
.
The function http_cookie_dup() duplicates a header structure hdr. If the header structure hdr contains a reference (hdr->x_next
) to a list of headers, all the headers in the list are duplicated, too.
home | memory home used to allocate new structure | |
hdr | header structure to be duplicated |
When duplicating, all parameter lists and non-constant strings attached to the header are copied, too. The function uses given memory home to allocate all the memory areas used to copy the header.
cookie = http_cookie_dup(home, http->http_cookie);
http_cookie_t * http_cookie_format | ( | su_home_t * | home, | |
char const * | fmt, | |||
... | ||||
) | [inline] |
Make a Cookie header from formatting result.
The function http_cookie_format() makes a new Cookie header object using formatting result as its value. The function first prints the arguments according to the format fmt specified. Then it allocates a new header structure, and uses the formatting result as the header value.
home | memory home used to allocate new header structure. | |
fmt | string used as a printf()-style format | |
... | argument list for format |
http_cookie_t* http_cookie_init | ( | http_cookie_t | x[1] | ) | [inline] |
Initialize a structure http_cookie_t.
An http_cookie_t structure can be initialized with the http_cookie_init() function/macro. For instance,
http_cookie_t http_cookie; http_cookie_init(&http_cookie);
http_cookie_t * http_cookie_make | ( | su_home_t * | home, | |
char const * | s | |||
) | [inline] |
Make a header structure http_cookie_t.
The function http_cookie_make() makes a new http_cookie_t header structure. It allocates a new header structure, and decodes the string s as the value of the structure.
home | memory home used to allocate new header structure. | |
s | string to be decoded as value of the new header structure |
int http_is_cookie | ( | http_header_t const * | header | ) | [inline] |
Test if header object is instance of http_cookie_t.
The function http_is_cookie() returns true (nonzero) if the header class is an instance of Cookie header object and false (zero) otherwise.
header | pointer to the header structure to be tested |
Header class for HTTP Cookie header.
The header class http_cookie_class defines how a HTTP Cookie header is parsed and printed. It also contains methods used by HTTP parser and other functions to manipulate the http_cookie_t header structure.