cookie.nx
buildroot/runtime/cookie.nx
about
cookie.nx -- parse HTTP Cookie header (RFC 6265 ยง4.2).
Parses the Cookie request header value:
"name1=value1; name2=value2; name3=value3"
This is the client-sent form that every HTTP server sees on
every authenticated request. Used for: session IDs, CSRF
tokens, language prefs, A/B flags. Nishi-pages + sovereign
HTTP handlers need this to validate session cookies.
Differences from query.nx:
- Separator is "; " (semicolon + space) per RFC, though we
also accept bare ";" for robustness.
- No percent-encoding on names; values may be quoted with
surrounding double-quotes (we strip them on parse).
- Empty values legal ("foo=; bar=baz") means cookie deletion.
Not handled here: Set-Cookie (the server-sent response header)
which has many more attributes (Path, Domain, Secure, HttpOnly,
SameSite, Max-Age, Expires). That's a separate set_cookie.nx
shipper for the writer side.
Invariants:
C1 Zero-alloc -- offsets into caller's buffer.
C2 Leading/trailing whitespace on names + values trimmed.
C3 Quoted values ("foo") have quotes stripped; embedded
escaped characters NOT unescaped today (RFC doesn't
specify quoted-string escape semantics for Cookie).
dependencies 1 imports · 0 importers
imports: syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 34 | struct CookieEntry { |
consts
| 32 | const COOKIE_ERR_OVERFLOW: i64 = -1 |
functions
| 40 | func cookie_is_ws(b: i64) -> i64 { |
| 47 | func cookie_ltrim(buf: *u8, off: i64, end: i64) -> i64 { |
| 57 | func cookie_rtrim(buf: *u8, start: i64, end: i64) -> i64 { |
| 68 | func cookie_parse(buf: *u8, n: i64, |
| 132 | func cookie_find(buf: *u8, entries: *CookieEntry, count: i64,
called by 1: main |
| 155 | func main() -> i64 { |