sysid / sse-starlette

BSD 3-Clause "New" or "Revised" License
504 stars 35 forks source link

Escaping Newlines #96

Closed CiberNin closed 1 month ago

CiberNin commented 2 months ago

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?

sysid commented 1 month ago

sse-starlette tries to implement the SSE standard. If there is a bug or misinterpretation, please let me know.