What Makes Text Stream Over HTTP
Server-Sent Events (SSE)
Part of: Streaming Writing Assistant
A normal HTTP response is one round trip: the client asks, the server computes everything, then sends it back as a single block. That's fine for a JSON reply. It's also exactly why a naive "AI writing assistant" endpoint feels frozen for several seconds before the whole essay dumps onto the screen at once. This project fixes that by keeping the connection open and sending the reply in pieces as it's generated. The protocol we'll use: SSE Server-Sent Events (SSE) is a plain-HTTP way to stream data from server to client, one direction only. There's no new protocol and no special port. The server keeps the connection open and writes small framed messages to it over time, so the response never quite finishes. Browsers and HTTP clients already read this format natively. An SSE frame has a strict, boring shape: a line starting with data: , then the payload, then a blank line that marks the end of that event. That trailing blank line (\n\n) is the delimiter, not decoration. Without it, a receiver can't tell where one chunk ends and the next begins. Why SSE instead of a WebSocket WebSockets are bidirectional and heavier to set up: a handshake, a different scheme, your own framing. A writin
Challenge: Frame the Stream