Limits and Timeouts
Body limits, route timeouts, in-flight limits and the other HTTP server settings.
The HTTP server carries its limits as settings on Server, and a route can override two of them with metadata. A setting that has no limit is named explicitly, so no setting is an Option: a count is Count { Default, Max(n), Unlimited } and a timeout is Bound { Default, After(d), Unbounded }.
Body limit
Server::new(endpoint).max_body(SERVER_LIMIT)The default is 2 MiB. A body over the limit fails with 413 before it is deserialised. #[meta(MaxBody(..))] overrides it for one route (examples/19-http-uploads; see Multipart).
Route timeouts
Timeout is declared metadata on a handler or on a #[handlers] impl, as in crates/ulo-http/tests/hand_written.rs:
use ulo_http::Timeout;
#[meta(Timeout::after(Duration::from_secs(5)))]When it passes, the execution is cancelled with the reason Deadline, and the error handlers receive a Timeout error under the server's timeout_grace (one second unless set). Unclaimed, it renders 504. The most specific declaration wins:
| Handler declares | Effect |
|---|---|
| nothing | the impl's timeout |
Timeout::after(d) | d |
Timeout::OFF | no timeout |
Timeout(Bound::Default) | the server's default, which is none |
An error handler's answer is delivered when it is a single reply produced within the grace. A body still open when the grace ends, an SSE stream among them, is dropped and the canonical 504 is written. A timeout that passes while a streamed reply is being written ends the stream in its mid-stream form and offers nothing to the error handlers.
Load shedding
max_inflight(Count) bounds the requests in flight, 1,024 unless set. A request over the limit gets a 503 with Retry-After before routing and before an execution opens, so it runs no pre-dispatch entry. shed_retry_after(Duration) sets the header's value, one second unless set. Count::Unlimited removes the bound.
Other settings
| Setting | Meaning |
|---|---|
max_concurrent_streams(Count) | HTTP/2 streams per connection |
header_timeout(Bound) | time to receive a request head, HTTP/1.1; 30 seconds unless set |
handshake_timeout(Bound) | TLS handshake; 30 seconds unless set |
timeout_grace(Bound) | how long error handlers get after a route timeout |
challenge(text) | the WWW-Authenticate value of a 401 whose error names none; Bearer unless set |
h2c(bool) | HTTP/2 without TLS |
tls(Tls) | TLS; see HTTP Servers |
A setting that would refuse everything it governs is a startup error: Bound::After(Duration::ZERO) on header_timeout, handshake_timeout or timeout_grace, Count::Max(0) on max_inflight or max_concurrent_streams, and a zero route timeout. Each message names the spelling of no limit: Bound::Unbounded, Count::Unlimited or Timeout::OFF.