code wiki / (root) / cors.nx

cors.nx

buildroot/runtime/cors.nx

5934 B167 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

cors.nx -- build CORS response headers. Fetch / XHR from a browser to a cross-origin server triggers CORS (Cross-Origin Resource Sharing). Browser sends a preflight OPTIONS request with Origin + Access-Control-Request-Method + Access-Control-Request-Headers. Server answers with Access- Control-Allow-* headers indicating what's permitted. Spec: Fetch Living Standard §Cors (supersedes the W3C CORS rec). Typical minimal response for a permissive public API: Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, POST, OPTIONS Access-Control-Allow-Headers: Content-Type, Authorization Access-Control-Max-Age: 86400 For credentialed requests (cookies / auth), Allow-Origin MUST echo the specific origin (not '*') and Allow-Credentials MUST be true. We expose both modes. Invariants: CO1 Stream builder; caller supplies an output buffer + offset. CO2 Headers include trailing CRLF; caller concatenates them after the HTTP status line.

dependencies 1 imports · 0 importers

syscalls.nx cors.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main cors_permissive cors_allow_origin co_put cors_allow_methods co_put ↻ cors_allow_headers co_put ↻ cors_max_age co_put ↻ cors_allow_origin ↻

structs

none

consts

28const CORS_ERR_SHORT: i64 = -1

functions

30func co_put(out: *u8, cap: i64, off: i64, src: *u8, n: i64) -> i64 {
42func cors_allow_origin(out: *u8, cap: i64, off: i64,
called by 2: cors_permissivemain calls 1: co_put
55func cors_allow_methods(out: *u8, cap: i64, off: i64,
called by 1: cors_permissive calls 1: co_put
68func cors_allow_headers(out: *u8, cap: i64, off: i64,
called by 1: cors_permissive calls 1: co_put
81func cors_expose_headers(out: *u8, cap: i64, off: i64,
calls 1: co_put
94func cors_allow_credentials(out: *u8, cap: i64, off: i64) -> i64 {
calls 1: co_put
102func cors_max_age(out: *u8, cap: i64, off: i64, seconds: i64) -> i64 {
called by 1: cors_permissive calls 1: co_put
135func cors_permissive(out: *u8, cap: i64, off: i64) -> i64 {
150func main() -> i64 {