tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Std: `std/http` resists slow and greedy clients (issue #220)

ADR 0012 Revision 2, implemented:

- **A deadline per request head.** `Settings.head_timeout` (10 s). Once a
  head has begun, the connection actor tells its watchdog once
  (`HeadStarted`) and sends nothing more until the head is read, so the
  reads no longer restart the timer: a head trickled a byte at a time is
  cut. `idle_timeout` keeps timing the wait for a request to start, and
  body reads.
- **A limit on open connections.** `Settings.max_open` (512). Watchdogs
  tell the acceptor when their connection ends — on `Stopped`, and when
  they close it on a timeout themselves, which used to go unreported.
  At the limit, `serve_with` waits for one to end before accepting.
- **A head is scanned once.** A head arriving in pieces goes into a
  builder; each read is scanned for the head's end with the 3 bytes
  before it (`tl_http_parse_head_end`, CRLF or bare LF, as httparse
  reads them), and the head is parsed once. It used to be copied and
  parsed again from its start on every read. Its 64 KiB limit is checked
  after each read and on the parsed head: a 70 KB head that arrived whole
  used to be served.
- **`accept` backs off** after a failure: 10 ms, doubling to 1 s.
- **One `Transfer-Encoding`:** `parse_head` refuses more (400).

Tests: `http_slow_and_greedy_clients` (new fixture `slow.lse`): a
trickled head closed at the 300 ms head timeout — the old server held it
as long as the client trickled, 7 s in a manual run; a kept-alive
connection idle past the head timeout still served; with `max_open`
connections held, the next one served once their watchdogs close them.
`http_rejects_malformed_requests` gains a repeated `Transfer-Encoding`
and heads over 64 KiB, whole and in two reads. Unit tests of the head's
end. Leak oracle at 0; the demo under load and its tests pass.

Left, and recorded in the ADR: a body trickled slowly is still timed per
read (a body deadline or minimum rate is for later).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

olivier · il y a 1 mois · 69980da01f81b5b46fe3f45bedff6ed8003e0d90

Parents 0e33712

10 fichiers modifiés, 418 ajouts, 48 suppressions