← Blog
0.7.0 · APPS · BROWSER

HTTP Response Parser — T12 Sprint (sigil-apps 294deab)

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

http_resp_parser.sg is the T12 sprint — parsing an HTTP/1.1 response at resp_buf @0x440000 into 9 structured fields stored at resp_parts_buf @0x450000 (9 × 8 B). Extracts: HTTP status code, reason phrase, Content-Type, Content-Length, Location header, and body offset. HTTP-RESP-PASS 7/7. 15432 B arm-el0.


Parse model

Status line + header field extraction

The parser scans bytes in resp_buf @0x440000 for HTTP/1.1 response structure. Status line: two spaces delimit the protocol version from the status code; a CR (written as poke8(..., 13) — Sigil has no \r escape) ends the status code and begins the reason phrase. Header scan: matches Content-Type, Content-Length, and Location header names; a blank line (CR+LF CR+LF) marks the body offset.

Results at resp_parts_buf @0x450000 (9 fields × 8 B each):

field 0
Status code (integer) — extracted between the first and second space on the status line.
fields 1–2
Reason phrase — (offset, length) pair; spans from after the second space to the CR that terminates the status line.
fields 3–4
Content-Type value — (offset, length) pair; matched by header name scan, value begins after the : separator.
fields 5–6
Content-Length value — (offset, length) pair; extracted the same way as Content-Type.
fields 7–8 (first pair)
Location value — (offset, length) pair; present when a redirect header is found; zero-filled if absent.
body offset (field 8, second)
Byte offset into resp_buf where the body begins — set when the blank-line terminator (CR+LF CR+LF) is found.

Test: 7 checks PASS. HTTP-RESP-PASS.

Note on implementation: CR is written via poke8(..., 13) rather than \r because Sigil's cc0 runtime has no \r escape sequence — a pattern that appears throughout the net parser suite.