-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SseEmitter should format a multiline String #30965
Comments
|
It adds the prefix, but only at the start of the entry - if the entry itself has multiple lines then it doesn't put the prefix at the start of every line (like you get for free in WebFlux IIUC). You can see what I mean in this sample: https://github.com/wimdeblauwe/blog-example-code/blob/master/htmx-sse/src/main/java/com/wimdeblauwe/examples/htmxsse/PdfGenerationController.java#L61 (he has to escape the new lines with |
We have tests for this. I will need a sample or something that demonstrates the issue. |
As for the PdfGenerationController, I think what you're pointing out seems to be about new lines within the data (XML, JSON) itself? I don't believe we support with WebFlux either. Again a sample would be best to proceed. |
I don't think any of those tests uses a multiline data. One of us is missing something. Here's a tiny sample: https://github.com/scratches/sse-sample (and a "webflux" branch that shows you don't need the workaround). |
@rstoyanchev Did you have time to check out the example of Dave? Any other information you need? |
@wimdeblauwe nothing further needed. Thanks for the sample @dsyer, I see what you mean now. |
The
ServerSentEventHttpMessageWriter
(used in Webflux but not MVC I think) has some logic to deal with multiline string data (e.g. when a@Controller
method returns aFlux<String>
):which produces correct output if the input text has multiple lines. In MVC you have to write an
SseEmitter
and send data to it, e.g.but the emitter doesn't check for multiline text and you don't get the
data:
prefix after the first line. I can work around it by usingtext.replace("\n", "\ndata:")
but it seems like I should expect Spring to do that for me, like it does in WebFlux.The text was updated successfully, but these errors were encountered: