Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_http_cookie.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
36
37#ifndef __NILOREA_HTTP_COOKIE_HEADER
38#define __NILOREA_HTTP_COOKIE_HEADER
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
48
49#include "nilorea/n_str.h"
50
51#include <stddef.h>
52
60
62#define N_HTTP_COOKIE_SESSION (-1LL)
63
65typedef struct N_HTTP_SET_COOKIE {
67 const char* name;
69 const char* value;
71 const char* path;
73 const char* domain;
76 long long max_age;
78 int secure;
84
97const char* n_http_cookie_get(const char* header, size_t len, const char* name, size_t* value_len);
98
104size_t n_http_cookie_count(const char* header, size_t len, const char* name);
105
119
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif /* __NILOREA_HTTP_COOKIE_HEADER */
int http_only
non-zero: HttpOnly
const char * value
cookie value, RFC 6265 cookie-octets only (may be "")
int secure
non-zero: Secure
const char * path
Path attribute, or NULL.
const char * name
cookie name, an RFC 9110 token
const char * domain
Domain attribute, or NULL (host-only cookie).
N_HTTP_SAMESITE same_site
SameSite attribute.
long long max_age
Max-Age in seconds; N_HTTP_COOKIE_SESSION for a session cookie; 0 deletes the cookie (Max-Age=0 plus ...
size_t n_http_cookie_count(const char *header, size_t len, const char *name)
count the pairs named name in a Cookie header value
N_HTTP_SAMESITE
SameSite attribute of a Set-Cookie.
int n_http_set_cookie_build(N_STR **out, const N_HTTP_SET_COOKIE *c)
append a Set-Cookie header value (without "Set-Cookie: ")
const char * n_http_cookie_get(const char *header, size_t len, const char *name, size_t *value_len)
find a cookie in a Cookie header value
@ N_HTTP_SAMESITE_NONE
SameSite=None, needs Secure.
@ N_HTTP_SAMESITE_STRICT
SameSite=Strict.
@ N_HTTP_SAMESITE_LAX
SameSite=Lax.
@ N_HTTP_SAMESITE_UNSET
no SameSite attribute (browser default)
what a Set-Cookie should carry
A box including a string and his lenght.
Definition n_str.h:61
N_STR and string function declaration.