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

add support for multiline data messages #19

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

igowen
Copy link
Contributor

@igowen igowen commented Apr 19, 2021

Currently, the data passed to Sender::send() is prepended with data: and written as-is. If the data string contains newlines, that causes any data beyond the newline(s) to end up on a line that does not begin with data:, which the spec dictates should be ignored (or, worse, if the message itself contains a field name, like event: or id:, after a newline, it could register on the client side as a separate event). This change splits the message on newlines and writes each line with its own data: prefix.

The decoder code seems to handle this case correctly already.

Currently, the `data` passed to `Sender::send()` is prepended with
`data:` and written as-is. If the data string contains newlines, that
causes any data beyond the newline(s) to end up on a line that does not
begin with `data:`, which the spec dictates should be ignored. This
change splits the message on newlines and writes each line with its own
`data:` prefix.
Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

This looks great, thanks so much!

@yoshuawuyts yoshuawuyts merged commit 56e5e4f into http-rs:main Sep 6, 2021
@igowen igowen deleted the multiline-messages branch September 6, 2021 18:55
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.

2 participants