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

Invalid event stream format for multiline data

Open decatur opened this issue 5 years ago • 0 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():

decatur avatar Jan 11 '21 22:01 decatur