tobogganSe connecter

louise

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

Std: streamed responses and Server-Sent Events (issue #179 §1a/§1b, ADR 0053)

A response body is now a Body: Whole(Bytes) (what body: Bytes was) or
Streamed(fn(Writer) -> ()). A streamed response sends its head with
Transfer-Encoding: chunked, then runs the stream fn in the connection's
actor: http.write_chunk/write_string frame and flush each chunk (one
write, nothing buffered), and the final chunk marker goes out when it
returns, with keep-alive intact after it. The watchdog learns Streaming:
between chunks a stream is not timed (SSE stays open for hours); each
chunk's write is timed per chunk by write_timeout — a stuck or gone
client ends the stream one chunk-time later, and the writer's Error is
what tells the handler to stop. A HEAD request is served as a GET with
no body (the RFC 9110 §9.3.2 mapping, now server-side: routers match
GET), and on a streamed route the stream fn is not called. A stream fn
that unwinds loses its connection without the final chunk: the client
sees a truncated stream, the only honest end once the status line is
sent.

std/http/sse is §1b: sse.stream (text/event-stream, Cache-Control:
no-cache), Event/new_event/frame (event:, id:, retry:, data: split on
newlines), comment (the heartbeat), last_event_id, send, and a small
broadcast Hub (subscribe/publish/unsubscribe) for actors pushing to
every open stream of a user.

Response stays a one-constructor record, so .headers/with_header/record
updates are unchanged; Response(s, h, bytes) becomes Response(s, h,
Whole(bytes)) — the demo's three sites adjusted. The demo gains /stream
(a page in chunks) and /events (heartbeat + four ticks); the end-to-end
test decodes chunked framing, checks HEAD, and serves a second request
on the same connection after a stream. ADR 0053 also settles how a
connection leaves the request/response loop (Body::Upgrading) for
WebSockets (§1c), whose frames and handshake are their own change.

olivier · il y a 1 mois · 2908e719babb9d71609440fd9ec7c129bbfeb2fa

Parents ca8cba9

8 fichiers modifiés, 633 ajouts, 18 suppressions