sse-starlette icon indicating copy to clipboard operation
sse-starlette copied to clipboard

Escaping Newlines

Open CiberNin opened this issue 10 months ago • 0 comments

I'm trying to use sse-starlette with datastar, which expects server sent events with fragments likefragment <div id='test'>\nUpdated\n</div> However it looks like starlette-sse always splits the data into multiple data lines when it encounters a newline. if self.data is not None: for chunk in self.LINE_SEP_EXPR.split(str(self.data)): buffer.write(f"data: {chunk}") buffer.write(self._sep) Unless my generator outputs bytes directly.

Is there any way to escape my newlines?

CiberNin avatar Apr 18 '24 15:04 CiberNin