SseEmitter support for multiline String
Closes gh-30965
This commit is contained in:
@@ -237,6 +237,9 @@ public class SseEmitter extends ResponseBodyEmitter {
|
||||
public SseEventBuilder data(Object object, @Nullable MediaType mediaType) {
|
||||
append("data:");
|
||||
saveAppendedText();
|
||||
if (object instanceof String text) {
|
||||
object = StringUtils.replace(text, "\n", "\ndata:");
|
||||
}
|
||||
this.dataToSend.add(new DataWithMediaType(object, mediaType));
|
||||
append('\n');
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user