This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 14048 - Suggestion of change in process for "dispatch the event" in Server-Sent Events
Summary: Suggestion of change in process for "dispatch the event" in Server-Sent Events
Status: RESOLVED INVALID
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Server-Sent Events (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: Other other
: P2 trivial
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-06 17:23 UTC by Eric Kever
Modified: 2011-10-18 20:29 UTC (History)
5 users (show)

See Also:


Attachments

Description Eric Kever 2011-09-06 17:23:48 UTC
This is pertinent to http://www.w3.org/TR/2011/WD-eventsource-20110310/, "Server-Sent Events"

In the section "Interpreting an event stream" under "dispatch the event," would it not be better to switch numbers 1 and 2 around?  Seeing that we want to abort on the empty string, if the only data in the string is LF, it would be stripped by step two, thus dispatching a MessageEvent with the empty string as its data anyways.

Currently, the lines are as follows:
1. If the data buffer is an empty string, set the data buffer and the event name buffer to the empty string and abort these steps.
2. If the data buffer's last character is a U+000A LINE FEED (LF) character, then remove the last character from the data buffer.

I would suggest:
1. If the data buffer's last character is a U+000A LINE FEED (LF) character, then remove the last character from the data buffer.
2. If the data buffer is an empty string, set the data buffer and the event name buffer to the empty string and abort these steps.
Comment 1 Per-Erik Brodin 2011-09-14 19:11:50 UTC
If the data buffer is an empty string in step 1 it means that there were no data: lines and that's why we want to abort.

If the data buffer contains only a line feed character in step 2 it means that there was exactly one data: line but it didn't have a value and thus a MessageEvent with an empty string as its data should be dispatched (similarly, two data: lines without values will result in event.data containing a single line feed character).
Comment 2 Ian 'Hixie' Hickson 2011-10-18 20:29:34 UTC
Exactly what comment 1 says.