code wiki / (root) / nx_multipart.nx

nx_multipart.nx

buildroot/runtime/nx_multipart.nx

6910 B199 linesdepth 2pulls 2 transitivereach 5 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

multipart.nx -- parse multipart/form-data bodies (RFC 7578). HTML <form enctype="multipart/form-data"> encodes each field as a separate "part" delimited by a boundary string announced in the Content-Type header: Content-Type: multipart/form-data; boundary=----WebKitFormBoundary Body structure (MIME): --BOUNDARY\r\n Content-Disposition: form-data; name="field1"\r\n \r\n value bytes\r\n --BOUNDARY\r\n Content-Disposition: form-data; name="file"; filename="a.txt"\r\n Content-Type: text/plain\r\n \r\n file bytes\r\n --BOUNDARY--\r\n (closing delimiter) We split the body into parts and surface each part's header block + body byte range. Callers parse the Content-Disposition line with content_type.nx to extract field name + filename. Invariants: MP1 Boundary string (without leading --) comes from the Content-Type parse; caller supplies it here. MP2 Final "--BOUNDARY--" delimiter stops parsing; parts after are ignored. MP3 Parts are surfaced with offsets into the caller's buffer; zero copies. MP4 \r\n between header and body must be present; malformed parts (missing blank line) are skipped.

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_multipart.nx nx_docportal_admin_daemon.nx

imports: nx_syscalls.nx

imported by: nx_docportal_admin_daemon.nx

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

main sys_mmap multipart_parse sys_mmap ↻ mp_find

structs

46struct MultipartPart

consts

43const MP_ERR_FORMAT: i64 = -1
44const MP_ERR_OVERFLOW: i64 = -2

functions

55func mp_find(buf: *u8, start: i64, n: i64,
called by 1: multipart_parse
78func multipart_parse(buf: *u8, n: i64,
called by 2: dad_uploadfilemain calls 2: sys_mmapmp_find
171func main() -> i64