multipart.nx
buildroot/runtime/multipart.nx
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
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
| 40 | struct MultipartPart { |
consts
| 37 | const MP_ERR_FORMAT: i64 = -1 |
| 38 | const MP_ERR_OVERFLOW: i64 = -2 |
functions
| 49 | func mp_find(buf: *u8, start: i64, n: i64,
called by 1: multipart_parse |
| 72 | func multipart_parse(buf: *u8, n: i64, |
| 160 | func main() -> i64 {
calls 1: multipart_parse |