aio-libs / aiohttp-sse

Server-sent events support for aiohttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid event stream format for multiline data

decatur opened this issue · comments

If data is multiline with \n as line separator (like in the provided examples/simple.py), the generated stream does not conform to the Server-Sent Events specification:

data: {
    "time": "Server Time : 2021-01-11 23:35:07.354653"
}

Expected is

data: {
data:    "time": "Server Time : 2021-01-11 23:35:07.354653"
data: }

Fix:
In aiohttp-sse.__init__, replace for chunk in data.split('\r\n'): with for chunk in data.splitlines():