Skip to content

Adds support for multi-line SSE event #10406

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spericas
Copy link
Member

Description

Adds support for multi-line SSE events. These are concatenated using '\n' on the client side and reported as a single event. See issue #10380.

Documentation

None

@spericas spericas added this to the 4.3.0 milestone Jul 21, 2025
@spericas spericas added this to Backlog Jul 21, 2025
@spericas spericas self-assigned this Jul 21, 2025
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 21, 2025
@spericas spericas requested a review from tvallin July 21, 2025 13:41
@spericas spericas marked this pull request as draft July 21, 2025 13:42
…'\n' on the client side and reported as a single event.
@spericas spericas marked this pull request as ready for review July 21, 2025 19:49
Copy link
Member

@tvallin tvallin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor questions otherwise looks good !

if (!(data instanceof String)) {
throw new IllegalArgumentException("Cannot concatenate non-string event data");
}
this.data += "\n" + data; // concatenate strings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/n is by the spec and is not a platform specific new line right ?

static void sseString2(ServerRequest req, ServerResponse res) {
try (SseSink sseSink = res.sink(SseSink.TYPE)) {
sseSink.emit(SseEvent.builder()
.data("first line")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add new method to create a multi line data event like this ?

Builder data(List<String> data);

or

Builder data(String... data);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x OCA Verified All contributors have signed the Oracle Contributor Agreement. webclient webserver
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants