// std/http/sse frames: the exact bytes of events and comments (Phase 5; // the builder-built frames must equal the concatenated ones). import std/http/sse import std/io pub fn main :: -> () / { // The documented example. io.println (debug (sse.frame sse.Event(..sse.new_event "two\nlines", id: Some("42")))) // Every field; newlines in `event:` and `id:` fold to spaces. io.println ( debug ( sse.frame sse.Event( ..sse.new_event "x" , event: Some("up\ndate") , id: Some("4\n2") , retry: Some(3000) ) ) ) // No optional fields; empty data still writes one `data:` line. io.println (debug (sse.frame (sse.new_event ""))) // A trailing newline is a last, empty data line. io.println (debug (sse.frame (sse.new_event "a\n"))) // Comments: the heartbeat, multi-line, and empty. io.println (debug (sse.comment "hb")) io.println (debug (sse.comment "a\nb")) io.println (debug (sse.comment "")) } //> b"id: 42\ndata: two\ndata: lines\n\n" //> b"event: up date\nid: 4 2\nretry: 3000\ndata: x\n\n" //> b"data: \n\n" //> b"data: a\ndata: \n\n" //> b": hb\n\n" //> b": a\n: b\n\n" //> b": \n\n"