Expand description
A minimal HTTP/1.1 server built directly on std::net.
No async runtime, no hyper, no tokio. Connections are handled by a
fixed thread pool. This is deliberately small: it keeps the binary tiny
and the request lifecycle trivial to reason about — for a human reading
the source, or an agent reasoning about the running app.
Structs§
- Limits
- Server resource limits — the difference between “demo” and “won’t fall over”.
- Request
- A parsed HTTP request.
- Response
- An HTTP response.
- SseSink
- A flushing sink that formats Server-Sent Events (
text/event-stream). Each call emits one event frame and flushes — exactly what LLM token streaming wants. - Stream
Sink - A flushing sink for raw streamed bytes. Every
writeis flushed so the client sees data immediately. - Thread
Pool - A fixed-size pool of worker threads pulling jobs off a shared channel.
Enums§
- Body
- A response body: either fully buffered, or streamed incrementally.
- Incoming
- The outcome of parsing: a request, or a refusal the server turns into 413.
- Method
- HTTP request methods sutegi recognizes.
Functions§
- parse_
request - Parse a single request off a buffered stream, enforcing
limits. ReturnsOk(None)if the peer closed before sending anything, orOk(Some(Incoming::TooLarge))if headers/body exceed the limits (so the server can reply 413 without allocating an attacker-chosen buffer). - serve
- Bind to
addrand serve requests withhandleruntil the process exits.handleris shared across worker threads, so it must beSend + Sync. - serve_
until - Like
serve, but stops accepting new connections onceshutdownis set, then drains in-flight requests (by dropping the pool, which joins workers) and returns. This is what makes a sutegi process safe to roll in a pod: on SIGTERM you flip the flag, stop taking traffic, and let live requests finish within the termination grace period. - status_
reason - Map a status code to its canonical reason phrase.
- write_
response - Write a response to the stream. Always closes the connection (no keep-alive)
to keep the server stateless and simple. Takes the response by value so a
streaming body’s
FnOnceproducer can be invoked.