Fix SSE data field to append instead of overwrite

Per the SSE specification, multiple data: lines within a single event
should be concatenated with newline separators. Previously, each data:
line overwrote the previous value.
This commit is contained in:
2026-01-31 06:40:45 +00:00
parent d1bd00ce95
commit f8a4323117

View File

@@ -73,7 +73,12 @@ impl Decoder for ServerSentEventsCodec {
self.next.event = Some(line);
} else if line.starts_with(DATA) {
line.drain(..DATA.len());
self.next.data = Some(line)
if let Some(ref mut existing) = self.next.data {
existing.push('\n');
existing.push_str(&line);
} else {
self.next.data = Some(line);
}
} else if line.starts_with(ID) {
line.drain(..ID.len());
self.next.id = Some(line);