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

Encode SSE based on HttpContentCodec (#2695) #2951

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

987Nabil
Copy link
Contributor

@987Nabil 987Nabil commented Jul 9, 2024

The current impl. of SSE uses special casing in the EncoderDecoder. Since we now have a generic way of handling en/decoding with HttpContentCodec, we don't need this anymore and can use a custom SSE content codec. This has also the benefit, that creating a codec for SSE and trying to change the content type, will lead to an error, since only text/event-stream has a codec defined.

I see this also as a fix to #2695. The issues arose because we selected application/json has the media type and it was flagged as binary in an old zio-http version. Which is no longer the case. But this fix prevents it from ever using any other content type then text/event-stream, except it is forced by the user.

Also, the encoding of SSE is currently bugged on main, since it is encoded as json based on the schema. This PR fixes that as well.

fixes #2695
/claim #2695

@987Nabil 987Nabil merged commit fdfde8e into zio:main Jul 30, 2024
34 checks passed
@987Nabil 987Nabil deleted the improve-sse-handling branch July 30, 2024 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClassCastException when running ServerSentEventEndpoint Example
2 participants