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

Refine resp_stream_sse() #652

Merged
merged 3 commits into from
Jan 24, 2025
Merged

Refine resp_stream_sse() #652

merged 3 commits into from
Jan 24, 2025

Conversation

hadley
Copy link
Member

@hadley hadley commented Jan 23, 2025

It's a bit difficult to translate the spec to the behaviour that we should implement, but I think this bullet:

If the data buffer is an empty string, set the data buffer and the event type buffer to the empty string and return.

Implies that if the event has no data, we should automatically wait for an event with data. This allows APIs to stream SSEs containing only comments to keep the stream alive. I think it makes sense to handle this hear, rather than requiring the end user to deal with it.

event$data is also now guaranteed to be a single string, which I think is easier to deal with.

Fixes #650

It's a bit difficult to translate the spec to the behaviour that we should implement, but I think this bullet:

> If the data buffer is an empty string, set the data buffer and the event type buffer to the empty string and return.

Implies that if the event has no data, we should automatically wait for an event with data. This allows APIs to stream SSEs containing only comments to keep the stream alive. I think it makes sense to handle this hear, rather than  requiring the end user to deal with it.

`event$data` is also now guaranteed to be a single string, which I think is easier to deal with.

Fixes #650
@hadley hadley requested a review from jcheng5 January 23, 2025 23:38
@hadley hadley merged commit c249b90 into main Jan 24, 2025
10 of 11 checks passed
@hadley hadley deleted the parse-stream-tweaking branch January 24, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resp_stream_sse() should return NULL when elements are empty
2 participants