basecamp / kamal-proxy

Lightweight proxy server for Kamal
https://kamal-deploy.org/
MIT License
754 stars 31 forks source link

Don't buffer SSE responses #36

Closed kevinmcconnell closed 1 month ago

kevinmcconnell commented 1 month ago

SSE requires being able to flush the response stream as each message is written. Response buffering gets in the way of this -- the messages will be flushed into the buffer, but the client won't see any of them until the response is closed.

To support SSE while allowing the use of response buffering elsewhere, we can add a bypass for responses that have Content-Type: text/event-stream that prevents them being buffered.

We'll also need to make sure that any custom ResponseWriters in the handler are Flush-able.

Fixes #34.