Skip to content

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