cc0/net/http_fetch.sg is the cc0 HTTP/1.1 client — a full GET/POST request builder and response parser operating above Cap<NetConn>. Supports both Content-Length and chunked transfer encoding, follows redirects up to 3 hops, and feeds the browser's fetch_cache and the VFS http_cache layers. Loopback stub rings used for QEMU testing. 7 QEMU tests PASS.
Request builder and response reader
http_fetch_get(conn, host, path): builds an HTTP/1.1 GET request — writes GET {path} HTTP/1.1\r\nHost: {host}\r\nConnection: close\r\n\r\n into the send buffer and dispatches over Cap<NetConn>. http_fetch_post(conn, host, path, body, body_len): builds an HTTP/1.1 POST request with Content-Length: {body_len} header and body. http_fetch_read_response(conn, buf, max_len): reads the raw response bytes from Cap<NetConn> into buf.
Chunked transfer encoding: the reader recognises Transfer-Encoding: chunked and reassembles chunk-size + CRLF + chunk-data + CRLF sequences into a linear body. Content-Length: the reader extracts the Content-Length: value and reads exactly that many body bytes after the blank-line header terminator. Redirect follow: if the response status is 301/302/303/307/308 and a Location: header is present, http_fetch_follow(conn, location, max_hops) re-issues the request up to 3 hops before giving up.
http_fetch_header_find(buf, name): scans the response buffer for a named header and returns its value's (offset, length). This is the primitive used by the caller to extract Content-Type, Content-Length, Cache-Control, ETag, etc. after http_fetch_read_response() returns.
Integration: fetch_cache.sg (browser in-process 16-slot cache) calls http_fetch_* to populate cache misses — when a URL isn't in the cache, http_fetch_get() is called, the response is stored in the cache slot, and subsequent requests return from cache without a network round-trip. http_cache.sg (VFS-backed response cache) uses the same layer for persistent caching across browser restarts. Loopback stub rings: separate send and recv ring buffers (not the same ring) simulate the server response in QEMU, allowing 7 tests to exercise GET, POST, chunked, Content-Length, redirect, header-find, and cache integration without a live network.