Once the calculator had a network, the next thing it needed was a way to fetch something. LWHTTP is that client. It follows the current HTTP specifications (RFC 9112 for message syntax and framing, RFC 9110 for semantics, RFC 3986 for URLs), and it fits in a 20 KB library on a machine with about 150 KB of free RAM.

Using it

Requests are asynchronous and stream through callbacks, so a response never has to fit in memory:

static bool on_response(lwhttp_client_t *client, void *arg)
{
  printf("HTTP/1.%u %u\n", lwhttp_client_version(client),
         lwhttp_client_status(client));
  return true;
}
 
static bool on_body(lwhttp_client_t *client, const uint8_t *data,
                    size_t len, void *arg)
{
  ((progress_t *)arg)->bytes += len;
  return true;
}
 
lwhttp_request_t request = {.url = "https://tls13.akamai.io/"};
lwhttp_client_request(client, &request, &handlers, &progress);
while (!progress.done) lwhttp_service_events();

This is what leaves the calculator for that request:

GET / HTTP/1.1
Host: tls13.akamai.io
User-Agent: LWHTTP/1.0.0-rc1
Accept-Encoding: identity

What it covers

AreaBehaviour
Field syntaxToken names, OWS trimming, obs-fold replaced by a space, bare LF accepted, CR, NUL and other control characters rejected.
Message lengthHEAD, 1xx, 204 and 304 have no body. Transfer-Encoding overrides Content-Length and disables reuse. Repeated lengths must agree.
Chunked transferChunk extensions (including quoted strings) skipped, trailer fields collected, chunk sizes bounds-checked.
Persistent connectionsReuse per origin, Connection: close and keep-alive honoured, one automatic retry for idempotent requests on a dead reused connection.
Request bodiesContent-Length for known sizes, chunked for streamed bodies, Expect: 100-continue. An early final response stops the upload.
Redirects301, 302, 303, 307, 308, relative references, method rewriting, credentials stripped across origins.
Upgrades101 and CONNECT tunnels hand the socket to the program, which is how WebSockets work on top of it.
HTTPSTLS 1.3 through lwIP-CE, with SNI and certificate verification.

Leaving things out was a deliberate choice too. Content decoding would need a 32 KB inflate window, which is most of the free RAM, so encoded responses are refused unless the program opts in. Cookies and caching are left to applications, which know what they can afford to keep. Pipelining is optional in RFC 9112 and badly supported by servers, so it isn't implemented.

Testing

The protocol code (parser, header store, writer, URLs) compiles for the host too. CI runs that suite with gcc and clang, under AddressSanitizer and UndefinedBehaviorSanitizer, and as a 32-bit build, plus libFuzzer harnesses for the parser and URL handling. The same suite then runs on the eZ80 inside HTTPTEST, a calculator program that also goes after real servers: keep-alive, chunked bodies, uploads, redirects, cancellation, parallel clients, TLS limits and WebSocket upgrades.

In CI that program runs in CEmu-lwIP-CE on a TAP interface, set up by cemu-net-action. Every push is tested against the network from an emulated calculator. A nightly build against lwIP-CE master catches upstream changes before a release does.