code wiki / (root) / multipart.nx

multipart.nx

buildroot/runtime/multipart.nx

6320 B188 linesdepth 3pulls 3 transitivereach 0 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 · 0 importers

syscalls.nx multipart.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 multipart_parse mp_find

structs

40struct MultipartPart {

consts

37const MP_ERR_FORMAT: i64 = -1
38const MP_ERR_OVERFLOW: i64 = -2

functions

49func mp_find(buf: *u8, start: i64, n: i64,
called by 1: multipart_parse
72func multipart_parse(buf: *u8, n: i64,
called by 1: main calls 1: mp_find
160func main() -> i64 {
calls 1: multipart_parse