Skip to main content

Module http

Module http 

Source
Expand description

Enough HTTP/1.1 to be an honest gateway, and no more.

Same reasoning as everywhere else in this workspace: probe.rs writes a raw GET because a health check is a status line; hearth-pull drives curl because a registry download needs TLS and resume, which is a real library’s job. This is the third case — a server on localhost speaking to clients that already exist, where the whole surface is read a request, write a response, and relay bytes. A framework would bring an async runtime and a dependency tree to do what four hundred lines of std does, and the parsing is the only part with a rule in it, so it lives here, pure and tested.

What this deliberately does NOT do: TLS (put it behind a proxy, and the default bind is loopback so there is nothing to expose), HTTP/2, or keep-alive pipelining. A model gateway handles a few requests per second that each take seconds; connection setup is not the cost.

Structs§

Request
A parsed request. Headers are lowercased on the way in, because HTTP header names are case-insensitive and half of the clients disagree about casing.
Server
The listening socket.

Functions§

parse_header
Parse one header line into a lowercased name and a trimmed value.
parse_request_line
Parse a request line. Pure — GET /v1/models HTTP/1.1.
proxy
Forward a request to a model’s endpoint and relay the response back.
read_request
Read one request off a stream.
render_response
Serialize a response we generated ourselves.