← Blog
0.7.0 · APPS · BROWSER

MIME Parser — T11 Sprint (sigil-apps c00d904)

June 23, 2026 · sigil-apps c00d904 · Sigil-Docs
apps browser net 0.7.0

mime_parser.sg is the T11 sprint — parsing a Content-Type header string at hdr_buf @0x420000 into 3 structured fields (type, subtype, charset) stored as (offset, length) pairs at mime_buf @0x430000 (16 B each). MIME-PARSER-PASS. 10136 B arm-el0.


Parse model

MIME type/subtype/charset extraction

hdr_buf @0x420000
Input: raw Content-Type header string. The parser scans bytes for the standard delimiters: / separates type from subtype, ; separates the media-type from the parameter list, charset= is the parameter key to match.
mime_buf @0x430000
Output: each field stored as a (len, off) pair — 16 B per field, two u64 fields. Field layout: offset 0 = type, offset 16 = subtype, offset 32 = charset. Charset field is empty (len=0) if no charset= parameter is present.

A rstrip() helper strips trailing spaces from the subtype before the ; delimiter using a saved-result exit pattern — exits the scan loop without a break instruction, a Sigil pattern for stripping trailing whitespace.

Test: 3 headers tested (e.g. text/html; charset=utf-8, application/json, multipart/form-data; charset=us-ascii), 9/9 component checks PASS. MIME-PARSER-PASS.