Skip to content
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

New implementation for SSE in webserver #9224

Merged
merged 5 commits into from
Sep 26, 2024
Merged

Conversation

spericas
Copy link
Member

@spericas spericas commented Aug 29, 2024

Description

Provides a new implementation for SSE in webserver. This implementation does not use the normal output stream to serialize the events to avoid problems with buffering and chunked encoding. Instead, it writes directly to the underlying socket writer and flushes data as needed. As a result, chunked encoding is no longer used for SSE. Several tests have been updated. Fixes #9164.

Summary of Changes

  1. New create method in SinkProvider that deprecates the old one. This change is required for the new implementation. Not a very popular SPI, but we shall continue to support the old method (and continue to include the old implemtnation) for some time. Class Http1ServerResponse updated accordingly.
  2. New SSE implementation in SseSink that writes directly to a writer. Also needs to write response status line and headers. No longer uses the output stream from the response.
  3. New SimpleSseClient class to test SSE endpoints without using WebClient. This is required because we don't use chunked encoding anymore. Related tests have been updated.

@spericas spericas added webserver 4.x Version 4.x labels Aug 29, 2024
@spericas spericas added this to the 4.1.2 milestone Aug 29, 2024
@spericas spericas self-assigned this Aug 29, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 29, 2024
@spericas spericas marked this pull request as draft August 29, 2024 20:10
@spericas spericas changed the title Provides a new implementation for SSE in the webserver Provides a new implementation for SSE in webserver Aug 29, 2024
…tation does not use the normal output stream to serialize the events to avoid problems with buffering and chunked encoding. Instead, it writes directly to the underlying socket writer and flushes data as needed. As a result, chunked encoding is no longer used for SSE. Several tests have been updated.
@spericas spericas force-pushed the issue-9164 branch 3 times, most recently from f22c2d3 to 7fc6e09 Compare August 30, 2024 14:31
Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com>
Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com>
Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com>
@spericas spericas marked this pull request as ready for review August 30, 2024 17:09
@spericas spericas changed the title Provides a new implementation for SSE in webserver New implementation for SSE in webserver Aug 30, 2024
…er SSE implementation, which is also kept around. Changes to SseSink to support multiple implementations.
Copy link
Member

@tomas-langer tomas-langer left a comment

Choose a reason for hiding this comment

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

LGTM
I would prefer not to use an anonymous inner class in server response though.

@spericas spericas merged commit 9e88500 into helidon-io:main Sep 26, 2024
44 checks passed
@barchetta barchetta mentioned this pull request Sep 26, 2024
16 tasks
barchetta pushed a commit to barchetta/helidon that referenced this pull request Sep 27, 2024
Provides a new implementation for SSE in the webserver. This implementation does not use the normal output stream to serialize the events to avoid problems with buffering and chunked encoding. Instead, it writes directly to the underlying socket writer and flushes data as needed. As a result, chunked encoding is no longer used for SSE. Several tests have been updated.
barchetta added a commit that referenced this pull request Sep 27, 2024
Provides a new implementation for SSE in the webserver. This implementation does not use the normal output stream to serialize the events to avoid problems with buffering and chunked encoding. Instead, it writes directly to the underlying socket writer and flushes data as needed. As a result, chunked encoding is no longer used for SSE. Several tests have been updated.

Co-authored-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com>
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. webserver
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Server-sent event (SSE) streams do not send a status-line until an event is emitted
2 participants