[html5] r1237 - /

whatwg at whatwg.org whatwg at whatwg.org
Fri Feb 22 01:43:03 PST 2008


Author: ianh
Date: 2008-02-22 01:43:02 -0800 (Fri, 22 Feb 2008)
New Revision: 1237

Modified:
   index
   source
Log:
[agowt] (2)  * Made it possible to adjust the reconnection timeout.

 * Made it so that the client tells the server what the last message it 
   received was when it reconnects, so as to allow seamless continuation. 

 * Rewrote the implementation processing requirements.

 * Simplified the event stream format:
    - removed the concept of 'commands'
    - changed the comment syntax from starting with a ';' to
      starting with a ':'

 * Removed the possibility to control anything of the event other than the 
   'data' and 'type' of the event.

 * Restricted the events that can be fired to all use MessageEvent.

 * Made 'message' events not bubble.

 * Made the MIME type of the new event stream format be
   text/event-stream; removed mention of the old format's type 
   (application/x-dom-event-stream).


Modified: index
===================================================================
--- index	2008-02-21 02:46:06 UTC (rev 1236)
+++ index	2008-02-22 09:43:02 UTC (rev 1237)
@@ -24,7 +24,7 @@
 
    <h1 id=html-5>HTML 5</h1>
 
-   <h2 class="no-num no-toc" id=working>Working Draft &mdash; 21 February
+   <h2 class="no-num no-toc" id=working>Working Draft &mdash; 22 February
     2008</h2>
 
    <p>You can take part in this work. <a
@@ -5851,7 +5851,8 @@
  &lt;/body&gt;
 &lt;/html&gt;</pre>
 
-   <p>...because the data placed in the cells is clearly not tabular data. A
+   <p>...because the data placed in the cells is clearly not tabular data
+    (and the <code><a href="#cite2">cite</a></code> element mis-used). A
     corrected version of this document might be:</p>
 
    <pre>&lt;!DOCTYPE html&gt;
@@ -5862,7 +5863,7 @@
    &lt;p&gt; My favourite animal is the cat. &lt;/p&gt;
   &lt;/blockquote&gt;
   &lt;p&gt;
-   &mdash;&lt;a href="http://example.org/~ernest/"&gt;&lt;cite&gt;Ernest&lt;/cite&gt;&lt;/a&gt;,
+   &mdash;&lt;a href="http://example.org/~ernest/"&gt;Ernest&lt;/a&gt;,
    in an essay from 1992
   &lt;/p&gt;
  &lt;/body&gt;
@@ -21118,7 +21119,7 @@
 
   <p>The <dfn id=src11 title=attr-event-source-src><code>src</code></dfn>
    attribute, if specified, must give a URI (or IRI) pointing to a resource
-   that uses the <code>application/x-dom-event-stream</code> format.
+   that uses the <code>text/event-stream</code> format.
 
   <p>When the element is inserted into the document, if it has the <code
    title=attr-event-source-src><a href="#src11">src</a></code> attribute
@@ -35455,17 +35456,30 @@
    buffering with different expected line endings can cause delays in event
    dispatch.
 
+  <p>Each event source in the list must have associated with it the
+   following:
+
+  <ul>
+   <li>The <dfn id=reconnection
+    title=concept-event-stream-reconnection-time>reconnection time</dfn>, in
+    milliseconds. This must initially be a user-agent-defined value, probably
+    in the region of a few seconds.
+
+   <li>The <dfn id=last-event title=concept-event-stream-last-event-id>last
+    event ID string</dfn>. This must initially be the empty string.
+  </ul>
+
   <p>In general, the semantics of the transport protocol specified by the
    URIs for the event sources must be followed, including HTTP caching rules.
 
   <p>For HTTP connections, the <code title="">Accept</code> header may be
    included; if included, it must only contain formats of event framing that
    are supported by the user agent (one of which must be
-   <code>application/x-dom-event-stream</code>, as described below).
+   <code>text/event-stream</code>, as described below).
 
   <p>Other formats of event framing may also be supported in addition to
-   <code>application/x-dom-event-stream</code>, but this specification does
-   not define how they are to be parsed or processed.
+   <code>text/event-stream</code>, but this specification does not define how
+   they are to be parsed or processed.
 
   <p class=note>Such formats could include systems like SMS-push; for example
    servers could use <code title="">Accept</code> headers and HTTP redirects
@@ -35475,16 +35489,22 @@
   <p>User agents should use the <code>Cache-Control: no-cache</code> header
    in requests to bypass any caches for requests of event sources.
 
+  <p>If the event source's last event ID string is not the empty string, then
+   a <code title="">Last-Event-ID</code> HTTP header must be included with
+   the request, whose value is the value of the event source's last event ID
+   string.
+
   <p>For connections to domains other than <a href="#domain0">the document's
    domain</a>, the semantics of the Access-Control HTTP header must be
-   followed. <a href="#refsACCESSCONTROL">[ACCESSCONTROL]</a>
+   followed. <a href="#refsACCESSCONTROL">[ACCESSCONTROL]</a> <!--
+  XXX define this better once that spec is more stable -->
+   
 
   <p>HTTP 200 OK responses with a <a href="#content-type8">Content-Type</a>
-   header specifying the type <code>application/x-dom-event-stream</code>
-   that are either from <a href="#domain0">the document's domain</a> or
-   explicitly allowed by the Access-Control HTTP headers must be processed
-   line by line <a href="#event-stream-interpretation">as described
-   below</a>.
+   header specifying the type <code>text/event-stream</code> that are either
+   from <a href="#domain0">the document's domain</a> or explicitly allowed by
+   the Access-Control HTTP headers must be processed line by line <a
+   href="#event-stream-interpretation">as described below</a>.
 
   <p>For the purposes of such successfully opened event streams only, user
    agents should ignore HTTP cache headers, and instead assume that the
@@ -35492,15 +35512,15 @@
 
   <p>If such a resource completes loading (i.e. the entire HTTP response body
    is received or the connection itself closes), the user agent should
-   request the event source resource again after a delay of approximately
-   five seconds.
+   request the event source resource again after a delay equal to the
+   reconnection time of the event source.
 
   <p>HTTP 200 OK responses that have a <a
    href="#content-type8">Content-Type</a> other than
-   <code>application/x-dom-event-stream</code> (or some other supported
-   type), and HTTP responses whose Access-Control headers indicate that the
-   resource are not to be used, must be ignored and must prevent the user
-   agent from refetching the resource for that event source.
+   <code>text/event-stream</code> (or some other supported type), and HTTP
+   responses whose Access-Control headers indicate that the resource are not
+   to be used, must be ignored and must prevent the user agent from
+   refetching the resource for that event source.
 
   <p>HTTP 201 Created, 202 Accepted, 203 Non-Authoritative Information, and
    206 Partial Content responses must be treated like HTTP 200 OK responses
@@ -35511,7 +35531,7 @@
   <p>HTTP 204 No Content, and 205 Reset Content responses must be treated as
    if they were 200 OK responses with the right MIME type but no content, and
    should therefore cause the user agent to refetch the resource after a
-   short delay.
+   delay equal to the reconnection time of the event source.
 
   <p>HTTP 300 Multiple Choices responses should be handled automatically if
    possible (treating the responses as if they were 302 Found responses
@@ -35532,8 +35552,8 @@
 
   <p>HTTP 304 Not Modified responses should be handled like HTTP 200 OK
    responses, with the content coming from the user agent cache. A new
-   request should then be made after a short delay of approximately five
-   seconds.
+   request should then be made after a delay equal to the reconnection time
+   of the event source.
 
   <p>HTTP 305 Use Proxy, HTTP 401 Unauthorized, and 407 Proxy Authentication
    Required should be treated transparently as for any other subresource.
@@ -35557,17 +35577,14 @@
 
   <h4 id=parsing1><span class=secno>6.2.3 </span>Parsing an event stream</h4>
 
-  <p>This event stream format's MIME type is
-   <code>application/x-dom-event-stream</code>.
+  <p>This event stream format's MIME type is <code>text/event-stream</code>.
 
   <p>The event stream format is (in pseudo-BNF):
 
   <pre>&lt;stream&gt;          ::= &lt;bom&gt;? &lt;event&gt;*
-&lt;event&gt;           ::= [ &lt;comment&gt; | &lt;command&gt; | &lt;field&gt; ]* &lt;newline&gt;
-&lt;comment&gt;         ::= ';' &lt;any-char&gt;* &lt;newline&gt;
-&lt;command&gt;         ::= ':' &lt;any-char&gt;* &lt;newline&gt;
-&lt;field&gt;           ::= &lt;name&gt; [ ':' &lt;space&gt;? &lt;any-char&gt;* ]? &lt;newline&gt;
-&lt;name&gt;            ::= &lt;name-start-char&gt; &lt;name-char&gt;*
+&lt;event&gt;           ::= [ &lt;comment&gt; | &lt;field&gt; ]* &lt;newline&gt;
+&lt;comment&gt;         ::= &lt;colon&gt; &lt;any-char&gt;* &lt;newline&gt;
+&lt;field&gt;           ::= &lt;name-char&gt;+ [ &lt;colon&gt; &lt;space&gt;? &lt;any-char&gt;* ]? &lt;newline&gt;
 
 # characters:
 &lt;bom&gt;             ::= a single U+FEFF BYTE ORDER MARK character
@@ -35577,309 +35594,166 @@
                       | a single U+000D CARRIAGE RETURN character
                       | a single U+000A LINE FEED character
                       | the end of the file
-&lt;name-start-char&gt; ::= a single Unicode character other than
-                      ':', ';', U+000D CARRIAGE RETURN and U+000A LINE FEED
+&lt;colon&gt;           ::= a single U+003A COLON character (':')
 &lt;name-char&gt;       ::= a single Unicode character other than
-                      ':', U+000D CARRIAGE RETURN and U+000A LINE FEED
+                      U+003A COLON, U+000D CARRIAGE RETURN and U+000A LINE FEED
 &lt;any-char&gt;        ::= a single Unicode character other than
                       U+000D CARRIAGE RETURN and U+000A LINE FEED
 </pre>
 
-  <p>Event streams in this format must always be encoded as UTF-8. Lines must
-   be separated by either a U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF)
-   character pair, a single U+000A LINE FEED (LF) character, or a single
-   U+000D CARRIAGE RETURN (CR) character. User agents must treat those three
-   variants as equivalent line terminators.
+  <p>Event streams in this format must always be encoded as UTF-8.
 
+  <p>Lines must be separated by either a U+000D CARRIAGE RETURN U+000A LINE
+   FEED (CRLF) character pair, a single U+000A LINE FEED (LF) character, or a
+   single U+000D CARRIAGE RETURN (CR) character.
+
+  <h4 id=event-stream-interpretation><span class=secno>6.2.4
+   </span>Interpreting an event stream</h4>
+
   <p>Bytes or sequences of bytes that are not valid UTF-8 sequences must be
    interpreted as the U+FFFD REPLACEMENT CHARACTER.
 
   <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if any are
    present.
 
-  <p>The stream must then be parsed by reading everything line by line, in
-   blocks separated by blank lines. Comment lines (those starting with the
-   character ';') and command lines (those starting with the character ':')
-   must be ignored.
+  <p>The stream must then be parsed by reading everything line by line, with
+   a U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair, a single
+   U+000A LINE FEED (LF) character, a single U+000D CARRIAGE RETURN (CR)
+   character, and the end of the file being the four ways in which a line can
+   end.
 
-  <p>Command lines are reserved for future extensions.</p>
-  <!--XXX Lachlan says:
-    For the next version of server sent events, it might be useful if
-    authors could specify the retry interval for connections.
+  <p>When a stream is parsed, a <var title="">data</var> buffer and an <var
+   title="">event name</var> buffer must be associated with it. They must be
+   initialized to the empty string
 
-    e.g. In cases where it is known that content is only updated at
-    specified intervals (e.g. once per minute), having the browser retry
-    the connection every 5 seconds and fire the event with the same
-    content may be excessive.
+  <p>Lines must be processed, in the order they are received, as follows:
 
-    This could possibly be done using the :command syntax.
+  <dl class=switch>
+   <dt>If the line is empty (a blank line)
 
-    e.g.
-      Event: click
-      :retry 60000
-
-    The browser would then retry the connection in 60,000 milliseconds (1
-    minute).
-  -->
-
-  <p>For each non-blank, non-comment, non-command line, the field name must
-   first be taken. This is everything on the line up to but not including the
-   first colon (':') or the line terminator, whichever comes first. Then, if
-   there was a colon, the data for that line must be taken. This is
-   everything after the colon, ignoring a single space after the colon if
-   there is one, up to the end of the line. If there was no colon the data is
-   the empty string.
-
-  <div class=example>
-   <p>Examples:</p>
-
-   <pre>Field name:&nbsp;Field data</pre>
-
-   <pre>This is a blank field</pre>
-
-   <pre>1. These two lines:&nbsp;have the same data
-2. These two lines:have the same data</pre>
-
-   <pre>1. But these two lines:&nbsp; do not
-2. But these two lines:&nbsp;do not</pre>
-  </div>
-
-  <p>If a field name occurs multiple times in a block, the value for that
-   field in that black must consist of the data parts for each of those
-   lines, concatenated with U+000A LINE FEED characters between them
-   (regardless of what the line terminators used in the stream actually are).
-
-  <div class=example>
-   <p>For example, the following block:</p>
-
-   <pre>Test:&nbsp;Line 1
-Foo:&nbsp;&nbsp;Bar
-Test:&nbsp;Line 2</pre>
-
-   <p>...is treated as having two fields, one called <code>Test</code> with
-    the value "<code>Line 1\nLine 2</code>" (where <code>\n</code> represents
-    a newline), and one called <code>Foo</code> with the value
-    "<code>&nbsp;Bar</code>" (note the leading space character).</p>
-  </div>
-
-  <p>A block thus consists of all the name-value pairs for its fields.
-   Command lines have no effect on blocks and are not considered part of a
-   block.
-
-  <p class=note>Since any random stream of characters matches the above
-   format, there is no need to define any error handling.
-
-  <h4 id=event-stream-interpretation><span class=secno>6.2.4
-   </span>Interpreting an event stream</h4>
-
-  <p>Once the fields have been parsed, they are interpreted as follows (these
-   are case-sensitive exact comparisons):
-
-  <dl>
-   <dt><code title="">Event</code> field
-
    <dd>
-    <p>This field gives the name of the event. For example, <code
-     title="">load</code>, <code title="">DOMActivate</code>, <code
-     title="">updateTicker</code>. If there is no field with this name, the
-     name <code title=event-message><a href="#message0">message</a></code>
-     must be used.
+    <p><a href="#dispatchMessage">Dispatch the event</a>, as defined below.
 
-   <dt><code title="">Namespace</code> field
+   <dt>If the line starts with a U+003A COLON character (':')
 
    <dd>
-    <p>This field gives the DOM3 namespace for the event. (For normal DOM
-     events this would be null.) If it isn't specified the event namespace is
-     null.
+    <p>Ignore the line.
 
-   <dt><code title="">Class</code> field
+   <dt>If the line contains a U+003A COLON character (':') character
 
    <dd>
-    <p>This field gives is the interface used for the event, for instance
-     <code>Event</code>, <code>UIEvent</code>, <code>MutationEvent</code>,
-     <code>KeyboardEvent</code>, etc. For compatibility with DOM3 Events, the
-     values <code title="">UIEvents</code>, <code
-     title="">MouseEvents</code>, <code title="">MutationEvents</code>, and
-     <code title="">HTMLEvents</code> are valid values and must be treated
-     respectively as meaning the interfaces <code>UIEvent</code>,
-     <code>MouseEvent</code>, <code>MutationEvent</code>, and
-     <code>Event</code>. (This value can therefore be used as the argument to
-     <code title="">createEvent()</code>.)</p>
+    <p>Collect the characters on the line before the first U+003A COLON
+     character (':'), and let <var title="">field</var> be that string.</p>
 
-    <p>If the value is not specified but the <code title="">Namespace</code>
-     is null and the <code title="">Event</code> field exactly matches one of
-     the events specified by DOM3 Events in <a
-     href="http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-EventTypes-complete">section
-     1.4.2 "Complete list of event types"</a>, then the interface used must
-     default to the interface relevant for that event type. <a
-     href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
+    <p>Collect the characters on the line after the first U+003A COLON
+     character (':'), and let <var title="">value</var> be that string. If
+     <var title="">value</var> starts with a single U+0020 SPACE character,
+     remove it from <var title="">value</var>.</p>
 
-    <div class=example>
-     <p>For example:</p>
+    <p><a href="#processField">Process the field</a> using the steps
+     described below, using <var title="">field</var> as the field name and
+     <var title="">value</var> as the field value.</p>
 
-     <pre>Event: click</pre>
+   <dt>Otherwise, the string is not empty but does not contain a U+003A COLON
+    character (':') character
 
-     <p>...would cause <code title="">Class</code> to be treated as
-      <code>MouseEvent</code>.</p>
-    </div>
+   <dd>
+    <p><a href="#processField">Process the field</a> using the steps
+     described below, using the the whole line as the field name, and the
+     empty string as the field value.</p>
+  </dl>
 
-    <p>If the <code title="">Namespace</code> is null and the <code
-     title="">Event</code> field is <code title=event-message><a
-     href="#message0">message</a></code> (including if it was not specified
-     explicitly), then the <code><a
-     href="#messageevent">MessageEvent</a></code> interface must be used.</p>
+  <p>Once the end of the file is reached, the user agent must <a
+   href="#dispatchMessage">dispatch the event</a> one final time, as defined
+   below.
 
-    <p>Otherwise, the <code>Event</code> interface must be used.</p>
+  <p id=processField>The steps to <dfn id=process title="">process the
+   field</dfn> given a field name and a field value depend on the field name,
+   as given in the following list. Field names must be compared literally,
+   with no case folding performed.
 
-    <p>It is quite possible to give the wrong class for an event. This is
-     equivalent to creating an event in the DOM using the DOM Event APIs, but
-     using the wrong interface for it.</p>
+  <dl class=switch>
+   <dt>If the field name is "event"
 
-   <dt><code title="">Bubbles</code> field
-
    <dd>
-    <p>This field specifies whether the event is to bubble. If it is
-     specified and has the value <code title="">No</code>, the event must not
-     bubble. If it is specified and has any other value (including <code
-     title="">no</code> or <code title="">NO</code>) then the event must
-     bubble.</p>
+    <p>Set the <var title="">event name</var> buffer the field value. <a
+     href="#refsXMLNS">[XMLNS]</a>
 
-    <p>If it is not specified but the <code title="">Namespace</code> field
-     is null and the <code title="">Event</code> field exactly matches one of
-     the events specified by DOM3 Events in <a
-     href="http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-EventTypes-complete">section
-     1.4.2 "Complete list of event types"</a>, then the event must bubble if
-     the DOM3 Events spec specifies that that event bubbles, and musn't
-     bubble if it specifies it does not. <a
-     href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
+   <dt>If the field name is "data"
 
-    <div class=example>
-     <p>For example:</p>
+   <dd>
+    <p>If the <var title="">data</var> buffer is not the empty string, then
+     append a single U+000A LINE FEED character to the <var
+     title="">data</var> buffer. Append the field value to the <var
+     title="">data</var> buffer.
 
-     <pre>Event: load</pre>
+   <dt>If the field name is "id"
 
-     <p>...would cause <code title="">Bubbles</code> to be treated as <code
-      title="">No</code>.</p>
-    </div>
-
-    <p>Otherwise, the event must bubble.</p>
-
-   <dt><code title="">Cancelable</code> field
-
    <dd>
-    <p>This field specifies whether the event can have its default action
-     prevented. If it is specified and has the value <code
-     title="">No</code>, the event must not be cancelable. If it is specified
-     and has any other value (including <code title="">no</code> or <code
-     title="">NO</code>) then the event must be cancelable.</p>
+    <p>Set the event stream's <a href="#last-event"
+     title=concept-event-stream-last-event-id>last event ID</a> to the field
+     value.
 
-    <p>If it is not specified, but the <code title="">Namespace</code> field
-     is null and the <code title="">Event</code> field exactly matches one of
-     the events specified by DOM3 Events in <a
-     href="http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-EventTypes-complete">section
-     1.4.2 "Complete list of event types"</a>, then the event must be
-     cancelable if the DOM3 Events specification specifies that it is, and
-     must not be cancelable otherwise. <a
-     href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
+   <dt>If the field name is "retry"
 
-    <div class=example>
-     <p>For example:</p>
-
-     <pre>Event: load</pre>
-
-     <p>...would cause <code title="">Cancelable</code> to be treated as
-      <code title="">No</code>.</p>
-    </div>
-
-    <p>Otherwise, the event must be cancelable.</p>
-
-   <dt><code title="">Target</code> field
-
    <dd>
-    <p>This field gives the node that the event is to be dispatched on.</p>
+    <p>If the field value consists of only characters in the range U+0030
+     DIGIT ZERO ('0') U+0039 DIGIT NINE ('9'), then interpret the field value
+     as an integer in base ten, and set the event stream's <a
+     href="#reconnection"
+     title=concept-event-stream-reconnection-time>reconnection time</a> to
+     that integer. Otherwise, ignore the field.
 
-    <p>If the object for which the event source is being processed is not a
-     Node, but the <code title="">Target</code> field is nonetheless
-     specified, then the event must be dropped.</p>
+   <dt>Otherwise
 
-    <p>Otherwise, if field is specified and its value starts with a <code
-     title="">#</code> character, then the remainder of the value represents
-     an ID, and the event must be dispatched on the same node as would be
-     obtained by the <code title="">getElementById()</code> method on the
-     <code title="">ownerDocument</code> of the node whose event source is
-     being processed.</p>
-
-    <div class=example>
-     <p>For example,</p>
-
-     <pre>Target: #test</pre>
-
-     <p>...would target the element with ID <code title="">test</code>.</p>
-    </div>
-
-    <p>Otherwise, if the field is specified and its value is the literal
-     string "<code title="">Document</code>", then the event must be
-     dispatched at the <code title="">ownerDocument</code> of the node whose
-     event source is being processed.</p>
-
-    <p>Otherwise, the field (whether specified or not) is ignored and the
-     event must be dispatched at the object itself.</p>
+   <dd>
+    <p>The field is ignored.
   </dl>
 
-  <p>Other fields depend on the interface specified (or possibly implied) by
-   the <code title="">Class</code> field. If the specified interface has an
-   attribute that exactly matches the name of the field, and the value of the
-   field can be converted (using the type conversions defined in ECMAScript)
-   to the type of the attribute, then it must be used. Any attributes (other
-   than the <code>Event</code> interface attributes) that do not have
-   matching fields are initialised to zero, null, false, or the empty string.
+  <p id=dispatchEvent>When the user agent is required to <dfn id=dispatch
+   title="">dispatch the event</dfn>, then the user agent must act as
+   follows:
 
-  <div class=example>
-   <p>For example:</p>
+  <ol>
+   <li>
+    <p>If the <var title="">data</var> buffer is an empty string, set the
+     <var title="">data</var> buffer and the <var title="">event name</var>
+     buffer to the empty string and abort these steps.
 
-   <pre>Event: click
-Class: MouseEvent
-button: 2</pre>
+   <li>
+    <p>If the <var title="">event name</var> buffer is not the empty string
+     but is also not a valid <a
+     href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>, set the
+     <var title="">data</var> buffer and the <var title="">event name</var>
+     buffer to the empty string and abort these steps.
 
-   <p>...would result in a 'click' event using the <code>MouseEvent</code>
-    interface that has <code>button</code> set to <code title="">2</code> but
-    <code>screenX</code>, <code>screenY</code>, etc, set to 0, false, or null
-    as appropriate.</p>
-  </div>
+   <li>
+    <p>Otherwise, create an event that uses the <code><a
+     href="#messageevent">MessageEvent</a></code> interface, with the event
+     name <code title=event-message><a href="#message0">message</a></code>,
+     which does not bubble, is cancelable, and has no default action. The
+     <code title=dom-MessageEvent-data><a href="#data4">data</a></code>
+     attribute must be set to the value of the <var title="">data</var>
+     buffer, the <code title=dom-MessageEvent-origin>origin</code> attribute
+     must be set to the <a href="#origin0">origin</a> of the event stream,
+     and the <code title=dom-MessageEvent-source><a
+     href="#source2">source</a></code> attribute must be set to null.
 
-  <p>If a field does not match any of the attributes on the event, it must be
-   ignored.
+   <li>
+    <p>If the <var title="">event name</var> buffer has a value other than
+     the empty string, change the type of the newly created event to equal
+     the value of the <var title="">event name</var> buffer.
 
-  <div class=example>
-   <p>For example:</p>
+   <li>
+    <p>Set the <var title="">data</var> buffer and the <var title="">event
+     name</var> buffer to the empty string.
 
-   <pre>Event: keypress
-Class: MouseEvent
-keyIdentifier: 0</pre>
+   <li>
+    <p>Dispatch the newly created event at the <code><a
+     href="#remoteeventtarget0">RemoteEventTarget</a></code> object to which
+     the event stream is registered.
+  </ol>
 
-   <p>...would result in a <code>MouseEvent</code> event with its fields all
-    at their default values, with the event name being <code
-    title="">keypress</code>. The <code title="">keyIdentifier</code> field
-    would be ignored. (If the author had not included the <code
-    title="">Class</code> field explicitly, it would have just worked, since
-    the class would have defaulted as described above.)</p>
-  </div>
-
-  <p>Once a blank line or the end of the file is reached, an event of the
-   type and namespace given by the <code title="">Event</code> and
-   <code>Namespace</code> fields respectively must be synthesized and
-   dispatched to the appropriate node as described by the fields above. No
-   event must be dispatched until a blank line has been received or the end
-   of the file reached.
-
-  <p>The event must be dispatched as if using the DOM <code
-   title="">dispatchEvent()</code> method. Thus, if the <code
-   title="">Event</code> field was omitted, leaving the name as the empty
-   string, or if the name had invalid characters, then the dispatching of the
-   event fails.
-
-  <p>Events fired from event sources do not have user-agent default actions.
-
   <div class=example>
    <p>The following event stream, once followed by a blank line:</p>
 
@@ -35890,11 +35764,10 @@
    <p>...would cause an event <code title=event-message><a
     href="#message0">message</a></code> with the interface <code><a
     href="#messageevent">MessageEvent</a></code> to be dispatched on the
-    <code><a href="#event-source">event-source</a></code> element, which
-    would then bubble up the DOM, and whose <code
-    title=dom-MessageEvent-data><a href="#data4">data</a></code> attribute
-    would contain the string <code>YHOO\n-2\n10</code> (where <code>\n</code>
-    again represents a newline).</p>
+    <code><a href="#event-source">event-source</a></code> element, whose
+    <code title=dom-MessageEvent-data><a href="#data4">data</a></code>
+    attribute would contain the string <code>YHOO\n-2\n10</code> (where
+    <code>\n</code> represents a newline).</p>
 
    <p>This could be used as follows:
 
@@ -35909,38 +35782,63 @@
   </div>
 
   <div class=example>
-   <p>The following stream contains four blocks and therefore fires four
-    events. The first block has just a comment, and will fire a <code
-    title=event-message><a href="#message0">message</a></code> event with all
-    the fields set to the empty string or null. The second block has two
-    fields with names "load" and "Target" respectively; since there is no
-    "<code title="">load</code>" member on the <code><a
-    href="#messageevent">MessageEvent</a></code> object that field is
-    ignored, leaving the event as a second <code title=event-message><a
-    href="#message0">message</a></code> event with all the fields set to the
-    empty string or null, but this time the event is targetted at an element
-    with ID "image1". The third block is empty (no lines between two blank
-    lines), and the fourth block has only two comments, so they both yet
-    again fire <code title=event-message><a
-    href="#message0">message</a></code> events with all the fields set to the
-    empty string or null.</p>
+   <p>The following stream contains four blocks. The first block has just a
+    comment, and will fire nothing. The second block has two fields with
+    names "data" and "id" respectively; an event will be fired for this
+    block, with the data "first event", and will then set the last event ID
+    to "1" so that if the connection died between this block and the next,
+    the server would be sent a <code title="">Last-Event-ID</code> header
+    with the value "1". The third block fires an event with data "second
+    event", and also has an "id" field, this time with no value, which resets
+    the last event ID to the empty string (meaning no code
+    title="">Last-Event-ID header will now be sent in the event of a
+    reconnection being attempted). Finally the last block just fires an event
+    with the data "third event". Note that the last block doesn't have to end
+    with a blank line, the end of the stream is enough to trigger the
+    dispatch of the last event.</p>
 
-   <pre>; test
+   <pre>: test stream
 
-load
-Target: #image1
+data: first event
+id: 1
 
+data: second event
+id
 
-; if any more events follow this block, they will not be affected by
-; the "Target" and "load" fields above.
-</pre>
+data: third event</pre>
   </div>
 
+  <div class=example>
+   <p>The following stream fires just one event:</p>
+
+   <pre>data
+
+data
+data
+
+data:</pre>
+
+   <p>The first and last blocks do nothing, since they do not contain any
+    actual data (the <var title="">data</var> buffer remains at the empty
+    string, and so nothing gets dispatched). The middle block fires an event
+    with the data set to a single newline character.</p>
+  </div>
+
+  <div class=example>
+   <p>The following stream fires two identical events:</p>
+
+   <pre>data:test
+
+data:&nbsp;test</pre>
+
+   <p>This is because the space after the colon is ignored if present.</p>
+  </div>
+
   <h4 id=notes><span class=secno>6.2.5 </span>Notes</h4>
 
   <p>Legacy proxy servers are known to, in certain cases, drop HTTP
    connections after a short timeout. To protect against such proxy servers,
-   authors can include a comment line (one starting with a ';' character)
+   authors can include a comment line (one starting with a ':' character)
    every 15 seconds or so.
 
   <p>Authors wishing to relate event source connections to each other or to
@@ -36892,10 +36790,11 @@
     <p>Create an event that uses the <code><a
      href="#messageevent">MessageEvent</a></code> interface, with the event
      name <code title=event-message><a href="#message0">message</a></code>,
-     which bubbles, is cancelable, and has no default action. The <code
-     title=dom-MessageEvent-data><a href="#data4">data</a></code> attribute
-     must be set to the value passed as the <var title="">message</var>
-     argument to the <code title=dom-window-postMessage><a
+     which does not bubble, is cancelable, and has no default action. The
+     <code title=dom-MessageEvent-data><a href="#data4">data</a></code>
+     attribute must be set to the value passed as the <var
+     title="">message</var> argument to the <code
+     title=dom-window-postMessage><a
      href="#postmessage">postMessage()</a></code> method, the <code
      title=dom-MessageEvent-origin>origin</code> attribute must be set to the
      <a href="#origin0">origin</a> of the document that the script that

Modified: source
===================================================================
--- source	2008-02-21 02:46:06 UTC (rev 1236)
+++ source	2008-02-22 09:43:02 UTC (rev 1237)
@@ -4441,7 +4441,8 @@
 &lt;/html&gt;</pre>
 
    <p>...because the data placed in the cells is clearly not tabular
-   data. A corrected version of this document might be:</p>
+   data (and the <code>cite</code> element mis-used). A corrected
+   version of this document might be:</p>
 
    <pre>&lt;!DOCTYPE html&gt;
 &lt;html lang="en-GB"&gt;
@@ -4451,7 +4452,7 @@
    &lt;p&gt; My favourite animal is the cat. &lt;/p&gt;
   &lt;/blockquote&gt;
   &lt;p&gt;
-   &mdash;&lt;a href="http://example.org/~ernest/"&gt;&lt;cite&gt;Ernest&lt;/cite&gt;&lt;/a&gt;,
+   &mdash;&lt;a href="http://example.org/~ernest/"&gt;Ernest&lt;/a&gt;,
    in an essay from 1992
   &lt;/p&gt;
  &lt;/body&gt;
@@ -18790,8 +18791,7 @@
 
   <p>The <dfn title="attr-event-source-src"><code>src</code></dfn>
   attribute, if specified, must give a URI (or IRI) pointing to a
-  resource that uses the <code>application/x-dom-event-stream</code>
-  format.</p>
+  resource that uses the <code>text/event-stream</code> format.</p>
 
   <p>When the element is inserted into the document, if it has the
   <code title="attr-event-source-src">src</code> attribute specified,
@@ -32767,7 +32767,8 @@
   <h4>The <dfn><code>RemoteEventTarget</code></dfn> interface</h4>
 
   <p>Any object that implements the <code>EventTarget</code> interface
-  must also implement the <code>RemoteEventTarget</code> interface.</p>
+  must also implement the <code>RemoteEventTarget</code>
+  interface.</p>
 
   <pre class="idl">interface <dfn>RemoteEventTarget</dfn> {
   void <span title="dom-RemoteEventTarget-addEventSource">addEventSource</span>(in DOMString src);
@@ -32818,6 +32819,22 @@
   FEED character, block buffering or line buffering with different
   expected line endings can cause delays in event dispatch.</p>
 
+  <p>Each event source in the list must have associated with it the
+  following:</p>
+
+  <ul>
+
+   <li>The <dfn
+   title="concept-event-stream-reconnection-time">reconnection
+   time</dfn>, in milliseconds. This must initially be a
+   user-agent-defined value, probably in the region of a few
+   seconds.</li>
+
+   <li>The <dfn title="concept-event-stream-last-event-id">last event
+   ID string</dfn>. This must initially be the empty string.</li>
+
+  </ul>
+
   <p>In general, the semantics of the transport protocol specified by
   the URIs for the event sources must be followed, including HTTP
   caching rules.</p>
@@ -32825,13 +32842,11 @@
   <p>For HTTP connections, the <code title="">Accept</code> header may
   be included; if included, it must only contain formats of event
   framing that are supported by the user agent (one of which must be
-  <code>application/x-dom-event-stream</code>, as described
-  below).</p>
+  <code>text/event-stream</code>, as described below).</p>
 
   <p>Other formats of event framing may also be supported in addition
-  to <code>application/x-dom-event-stream</code>, but this
-  specification does not define how they are to be parsed or
-  processed.</p>
+  to <code>text/event-stream</code>, but this specification does not
+  define how they are to be parsed or processed.</p>
 
   <p class="note">Such formats could include systems like SMS-push;
   for example servers could use <code title="">Accept</code> headers
@@ -32842,16 +32857,21 @@
   header in requests to bypass any caches for requests of event
   sources.</p>
 
+  <p>If the event source's last event ID string is not the empty
+  string, then a <code title="">Last-Event-ID</code> HTTP header must
+  be included with the request, whose value is the value of the event
+  source's last event ID string.</p>
+
   <p>For connections to domains other than <span>the document's
   domain</span>, the semantics of the Access-Control HTTP header must
-  be followed. <a href="#refsACCESSCONTROL">[ACCESSCONTROL]</a>
+  be followed. <a href="#refsACCESSCONTROL">[ACCESSCONTROL]</a> <!--
+  XXX define this better once that spec is more stable -->
 
   <p>HTTP 200 OK responses with a <span>Content-Type</span> header
-  specifying the type <code>application/x-dom-event-stream</code> that
-  are either from <span>the document's domain</span> or explicitly
-  allowed by the Access-Control HTTP headers must be processed line by
-  line <a href="#event-stream-interpretation">as described
-  below</a>.</p>
+  specifying the type <code>text/event-stream</code> that are either
+  from <span>the document's domain</span> or explicitly allowed by the
+  Access-Control HTTP headers must be processed line by line <a
+  href="#event-stream-interpretation">as described below</a>.</p>
 
   <p>For the purposes of such successfully opened event streams only,
   user agents should ignore HTTP cache headers, and instead assume
@@ -32860,14 +32880,13 @@
   <p>If such a resource completes loading (i.e. the entire HTTP
   response body is received or the connection itself closes), the user
   agent should request the event source resource again after a delay
-  of approximately five seconds.</p>
+  equal to the reconnection time of the event source.</p>
 
   <p>HTTP 200 OK responses that have a <span>Content-Type</span> other
-  than <code>application/x-dom-event-stream</code> (or some other
-  supported type), and HTTP responses whose Access-Control headers
-  indicate that the resource are not to be used, must be ignored and
-  must prevent the user agent from refetching the resource for that
-  event source.</p>
+  than <code>text/event-stream</code> (or some other supported type),
+  and HTTP responses whose Access-Control headers indicate that the
+  resource are not to be used, must be ignored and must prevent the
+  user agent from refetching the resource for that event source.</p>
 
   <p>HTTP 201 Created, 202 Accepted, 203 Non-Authoritative
   Information, and 206 Partial Content responses must be treated like
@@ -32879,7 +32898,8 @@
   <p>HTTP 204 No Content, and 205 Reset Content responses must be
   treated as if they were 200 OK responses with the right MIME type
   but no content, and should therefore cause the user agent to refetch
-  the resource after a short delay.</p>
+  the resource after a delay equal to the reconnection time of the
+  event source.</p>
 
   <p>HTTP 300 Multiple Choices responses should be handled
   automatically if possible (treating the responses as if they were
@@ -32901,8 +32921,8 @@
 
   <p>HTTP 304 Not Modified responses should be handled like HTTP 200
   OK responses, with the content coming from the user agent cache. A
-  new request should then be made after a short delay of approximately
-  five seconds.</p>
+  new request should then be made after a delay equal to the
+  reconnection time of the event source.</p>
 
   <p>HTTP 305 Use Proxy, HTTP 401 Unauthorized, and 407 Proxy
   Authentication Required should be treated transparently as for any
@@ -32928,16 +32948,14 @@
   <h4>Parsing an event stream</h4>
 
   <p>This event stream format's MIME type is
-  <code>application/x-dom-event-stream</code>.</p>
+  <code>text/event-stream</code>.</p>
 
   <p>The event stream format is (in pseudo-BNF):</p>
 
   <pre>&lt;stream&gt;          ::= &lt;bom&gt;? &lt;event&gt;*
-&lt;event&gt;           ::= [ &lt;comment&gt; | &lt;command&gt; | &lt;field&gt; ]* &lt;newline&gt;
-&lt;comment&gt;         ::= ';' &lt;any-char&gt;* &lt;newline&gt;
-&lt;command&gt;         ::= ':' &lt;any-char&gt;* &lt;newline&gt;
-&lt;field&gt;           ::= &lt;name&gt; [ ':' &lt;space&gt;? &lt;any-char&gt;* ]? &lt;newline&gt;
-&lt;name&gt;            ::= &lt;name-start-char&gt; &lt;name-char&gt;*
+&lt;event&gt;           ::= [ &lt;comment&gt; | &lt;field&gt; ]* &lt;newline&gt;
+&lt;comment&gt;         ::= &lt;colon&gt; &lt;any-char&gt;* &lt;newline&gt;
+&lt;field&gt;           ::= &lt;name-char&gt;+ [ &lt;colon&gt; &lt;space&gt;? &lt;any-char&gt;* ]? &lt;newline&gt;
 
 # characters:
 &lt;bom&gt;             ::= a single U+FEFF BYTE ORDER MARK character
@@ -32947,21 +32965,24 @@
                       | a single U+000D CARRIAGE RETURN character
                       | a single U+000A LINE FEED character
                       | the end of the file
-&lt;name-start-char&gt; ::= a single Unicode character other than
-                      ':', ';', U+000D CARRIAGE RETURN and U+000A LINE FEED
+&lt;colon&gt;           ::= a single U+003A COLON character (':')
 &lt;name-char&gt;       ::= a single Unicode character other than
-                      ':', U+000D CARRIAGE RETURN and U+000A LINE FEED
+                      U+003A COLON, U+000D CARRIAGE RETURN and U+000A LINE FEED
 &lt;any-char&gt;        ::= a single Unicode character other than
                       U+000D CARRIAGE RETURN and U+000A LINE FEED
 </pre>
 
   <p>Event streams in this format must always be encoded as
-  UTF-8. Lines must be separated by either a U+000D CARRIAGE RETURN
-  U+000A LINE FEED (CRLF) character pair, a single U+000A LINE FEED
-  (LF) character, or a single U+000D CARRIAGE RETURN (CR)
-  character. User agents must treat those three variants as equivalent
-  line terminators.</p>
+  UTF-8.</p>
 
+  <p>Lines must be separated by either a U+000D CARRIAGE RETURN U+000A
+  LINE FEED (CRLF) character pair, a single U+000A LINE FEED (LF)
+  character, or a single U+000D CARRIAGE RETURN (CR) character.</p>
+
+
+
+  <h4 id="event-stream-interpretation">Interpreting an event stream</h4>
+
   <p>Bytes or sequences of bytes that are not valid UTF-8 sequences
   must be interpreted as the U+FFFD REPLACEMENT CHARACTER.</p>
 
@@ -32969,297 +32990,157 @@
   any are present.</p>
 
   <p>The stream must then be parsed by reading everything line by
-  line, in blocks separated by blank lines. Comment lines (those
-  starting with the character ';') and command lines (those starting
-  with the character ':') must be ignored.</p>
+  line, with a U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF)
+  character pair, a single U+000A LINE FEED (LF) character, a single
+  U+000D CARRIAGE RETURN (CR) character, and the end of the file being
+  the four ways in which a line can end.</p>
 
-  <p>Command lines are reserved for future extensions.</p>
+  <p>When a stream is parsed, a <var title="">data</var> buffer and an
+  <var title="">event name</var> buffer must be associated with
+  it. They must be initialized to the empty string</p>
 
-  <!--XXX Lachlan says:
-    For the next version of server sent events, it might be useful if
-    authors could specify the retry interval for connections.
+  <p>Lines must be processed, in the order they are received, as
+  follows:</p>
 
-    e.g. In cases where it is known that content is only updated at
-    specified intervals (e.g. once per minute), having the browser retry
-    the connection every 5 seconds and fire the event with the same
-    content may be excessive.
+  <dl class="switch">
 
-    This could possibly be done using the :command syntax.
+   <dt>If the line is empty (a blank line)</dt>
 
-    e.g.
-      Event: click
-      :retry 60000
+   <dd><p><a href="#dispatchMessage">Dispatch the event</a>, as
+   defined below.</p></dd>
 
-    The browser would then retry the connection in 60,000 milliseconds (1
-    minute).
-  -->
 
-  <p>For each non-blank, non-comment, non-command line, the field name
-  must first be taken. This is everything on the line up to but not
-  including the first colon (':') or the line terminator, whichever
-  comes first. Then, if there was a colon, the data for that line must
-  be taken. This is everything after the colon, ignoring a single
-  space after the colon if there is one, up to the end of the line. If
-  there was no colon the data is the empty string.</p>
+   <dt>If the line starts with a U+003A COLON character (':')</dt>
 
-  <div class="example">
-   <p>Examples:</p>
-   <pre>Field name:&nbsp;Field data</pre>
-   <pre>This is a blank field</pre>
-   <pre>1. These two lines:&nbsp;have the same data
-2. These two lines:have the same data</pre>
-   <pre>1. But these two lines:&nbsp; do not
-2. But these two lines:&nbsp;do not</pre>
-  </div>
+   <dd><p>Ignore the line.</p></dd>
 
-  <p>If a field name occurs multiple times in a block, the value for
-  that field in that black must consist of the data parts for each of
-  those lines, concatenated with U+000A LINE FEED characters between
-  them (regardless of what the line terminators used in the stream
-  actually are).</p>
 
-  <div class="example">
-   <p>For example, the following block:</p>
-   <pre>Test:&nbsp;Line 1
-Foo:&nbsp;&nbsp;Bar
-Test:&nbsp;Line 2</pre>
-   <p>...is treated as having two fields, one called <code>Test</code>
-   with the value "<code>Line 1\nLine 2</code>" (where <code>\n</code>
-   represents a newline), and one called <code>Foo</code> with the
-   value "<code>&nbsp;Bar</code>" (note the leading space
-   character).</p>
-  </div>
+   <dt>If the line contains a U+003A COLON character (':') character</dt>
 
-  <p>A block thus consists of all the name-value pairs for its
-  fields. Command lines have no effect on blocks and are not
-  considered part of a block.</p>
+   <dd>
 
-  <p class="note">Since any random stream of characters matches the above
-  format, there is no need to define any error handling.</p>
+    <p>Collect the characters on the line before the first U+003A
+    COLON character (':'), and let <var title="">field</var> be that
+    string.</p>
 
+    <p>Collect the characters on the line after the first U+003A COLON
+    character (':'), and let <var title="">value</var> be that
+    string. If <var title="">value</var> starts with a single U+0020
+    SPACE character, remove it from <var title="">value</var>.</p>
 
-  <h4 id="event-stream-interpretation">Interpreting an event stream</h4>
+    <p><a href="#processField">Process the field</a> using the steps
+    described below, using <var title="">field</var> as the field name
+    and <var title="">value</var> as the field value.</p>
 
-  <p>Once the fields have been parsed, they are interpreted as follows
-  (these are case-sensitive exact comparisons):</p>
+   </dd>
 
-  <dl>
 
-   <dt><code title="">Event</code> field</dt>
+   <dt>Otherwise, the string is not empty but does not contain a U+003A COLON character (':') character</dt>
 
-   <dd><p>This field gives the name of the event. For example, <code
-   title="">load</code>, <code title="">DOMActivate</code>, <code
-   title="">updateTicker</code>. If there is no field with this name,
-   the name <code title="event-message">message</code> must be
-   used.</p></dd>
-
-
-   <dt><code title="">Namespace</code> field</dt>
-
-   <dd><p>This field gives the DOM3 namespace for the event. (For
-   normal DOM events this would be null.) If it isn't specified the
-   event namespace is null.</p></dd>
-
-
-   <dt><code title="">Class</code> field</dt>
-
    <dd>
 
-    <p>This field gives is the interface used for the event, for
-    instance <code>Event</code>, <code>UIEvent</code>,
-    <code>MutationEvent</code>, <code>KeyboardEvent</code>, etc. For
-    compatibility with DOM3 Events, the values <code
-    title="">UIEvents</code>, <code title="">MouseEvents</code>, <code
-    title="">MutationEvents</code>, and <code
-    title="">HTMLEvents</code> are valid values and must be treated
-    respectively as meaning the interfaces <code>UIEvent</code>,
-    <code>MouseEvent</code>, <code>MutationEvent</code>, and
-    <code>Event</code>. (This value can therefore be used as the
-    argument to <code title="">createEvent()</code>.)</p>
+    <p><a href="#processField">Process the field</a> using the steps
+    described below, using the the whole line as the field name, and
+    the empty string as the field value.</p>
 
-    <p>If the value is not specified but the <code
-    title="">Namespace</code> is null and the <code
-    title="">Event</code> field exactly matches one of the events
-    specified by DOM3 Events in <a
-    href="http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-EventTypes-complete">section
-    1.4.2 "Complete list of event types"</a>, then the interface used
-    must default to the interface relevant for that event type. <a
-    href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
-
-    <div class="example">
-     <p>For example:</p>
-     <pre>Event: click</pre>
-     <p>...would cause <code title="">Class</code> to be treated as <code>MouseEvent</code>.</p>
-    </div>
-
-    <p>If the <code title="">Namespace</code> is null and the <code
-    title="">Event</code> field is <code
-    title="event-message">message</code> (including if it was not
-    specified explicitly), then the <code>MessageEvent</code>
-    interface must be used.</p>
-
-    <p>Otherwise, the <code>Event</code> interface must be used.</p>
-
-    <p>It is quite possible to give the wrong class for an event. This
-    is equivalent to creating an event in the DOM using the DOM Event
-    APIs, but using the wrong interface for it.</p>
-
    </dd>
 
+  </dl>
 
-   <dt><code title="">Bubbles</code> field</dt>
+  <p>Once the end of the file is reached, the user agent must <a
+  href="#dispatchMessage">dispatch the event</a> one final time, as
+  defined below.</p></dd>
 
-   <dd>
 
-    <p>This field specifies whether the event is to bubble. If it is
-    specified and has the value <code title="">No</code>, the event
-    must not bubble. If it is specified and has any other value
-    (including <code title="">no</code> or <code title="">NO</code>)
-    then the event must bubble.</p>
+  <p id="processField">The steps to <dfn title="">process the
+  field</dfn> given a field name and a field value depend on the field
+  name, as given in the following list. Field names must be compared
+  literally, with no case folding performed.</p>
 
-    <p>If it is not specified but the <code title="">Namespace</code>
-    field is null and the <code title="">Event</code> field exactly
-    matches one of the events specified by DOM3 Events in <a
-    href="http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-EventTypes-complete">section
-    1.4.2 "Complete list of event types"</a>, then the event must
-    bubble if the DOM3 Events spec specifies that that event bubbles,
-    and musn't bubble if it specifies it does not.  <a
-    href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
+  <dl class="switch">
 
-    <div class="example">
-     <p>For example:</p>
-     <pre>Event: load</pre>
-     <p>...would cause <code title="">Bubbles</code> to be treated as <code title="">No</code>.</p>
-    </div>
+   <dt>If the field name is "event"</dt>
 
-    <p>Otherwise, the event must bubble.</p>
+   <dd><p>Set the <var title="">event name</var> buffer the field
+   value. <a href="#refsXMLNS">[XMLNS]</a></p></dd>
 
-   </dd>
 
-   <dt><code title="">Cancelable</code> field</dt>
+   <dt>If the field name is "data"</dt>
 
-   <dd>
+   <dd><p>If the <var title="">data</var> buffer is not the empty
+   string, then append a single U+000A LINE FEED character to the <var
+   title="">data</var> buffer. Append the field value to the <var
+   title="">data</var> buffer.</p></dd>
 
-    <p>This field specifies whether the event can have its default
-    action prevented. If it is specified and has the value <code
-    title="">No</code>, the event must not be cancelable. If it is
-    specified and has any other value (including <code
-    title="">no</code> or <code title="">NO</code>) then the event
-    must be cancelable.</p>
 
-    <p>If it is not specified, but the <code title="">Namespace</code>
-    field is null and the <code title="">Event</code> field exactly
-    matches one of the events specified by DOM3 Events in <a
-    href="http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-EventTypes-complete">section
-    1.4.2 "Complete list of event types"</a>, then the event must be
-    cancelable if the DOM3 Events specification specifies that it is,
-    and must not be cancelable otherwise. <a
-    href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
+   <dt>If the field name is "id"</dt>
 
-    <div class="example">
-     <p>For example:</p>
-     <pre>Event: load</pre>
-     <p>...would cause <code title="">Cancelable</code> to be treated as <code title="">No</code>.</p>
-    </div>
+   <dd><p>Set the event stream's <span
+   title="concept-event-stream-last-event-id">last event ID</span> to
+   the field value.</p></dd>
 
-    <p>Otherwise, the event must be cancelable.</p>
 
-   </dd>
+   <dt>If the field name is "retry"</dt>
 
+   <dd><p>If the field value consists of only characters in the range
+   U+0030 DIGIT ZERO ('0') U+0039 DIGIT NINE ('9'), then interpret the
+   field value as an integer in base ten, and set the event stream's
+   <span title="concept-event-stream-reconnection-time">reconnection
+   time</span> to that integer. Otherwise, ignore the field.</p></dd>
 
-   <dt><code title="">Target</code> field</dt>
 
-   <dd>
+   <dt>Otherwise</dt>
 
-    <p>This field gives the node that the event is to be dispatched
-    on.</p>
+   <dd><p>The field is ignored.</p></dd>
 
-    <p>If the object for which the event source is being processed is
-    not a Node, but the <code title="">Target</code> field is
-    nonetheless specified, then the event must be dropped.</p>
+  </dl>
 
-    <p>Otherwise, if field is specified and its value starts with a
-    <code title="">#</code> character, then the remainder of the value
-    represents an ID, and the event must be dispatched on the same
-    node as would be obtained by the <code
-    title="">getElementById()</code> method on the <code
-    title="">ownerDocument</code> of the node whose event source is
-    being processed.</p>
 
-    <div class="example">
-     <p>For example,</p>
-     <pre>Target: #test</pre>
-     <p>...would target the element with ID <code title="">test</code>.</p>
-    </div>
+  <p id="dispatchEvent">When the user agent is required to <dfn
+  title="">dispatch the event</dfn>, then the user agent must act as follows:
 
-    <p>Otherwise, if the field is specified and its value is the
-    literal string "<code title="">Document</code>", then the event
-    must be dispatched at the <code title="">ownerDocument</code> of
-    the node whose event source is being processed.</p>
+  <ol>
 
-    <p>Otherwise, the field (whether specified or not) is ignored and
-    the event must be dispatched at the object itself.</p>
+   <li><p>If the <var title="">data</var> buffer is an empty string,
+   set the <var title="">data</var> buffer and the <var title="">event
+   name</var> buffer to the empty string and abort these
+   steps.</p></li>
 
-   </dd>
+   <li><p>If the <var title="">event name</var> buffer is not the
+   empty string but is also not a valid <a
+   href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>,
+   set the <var title="">data</var> buffer and the <var title="">event
+   name</var> buffer to the empty string and abort these
+   steps.</p></li>
+   
+   <li><p>Otherwise, create an event that uses the
+   <code>MessageEvent</code> interface, with the event name <code
+   title="event-message">message</code>, which does not bubble, is
+   cancelable, and has no default action. The <code
+   title="dom-MessageEvent-data">data</code> attribute must be set to
+   the value of the <var title="">data</var> buffer, the <code
+   title="dom-MessageEvent-origin">origin</code> attribute must be set
+   to the <span>origin</span> of the event stream, and the <code
+   title="dom-MessageEvent-source">source</code> attribute must be set
+   to null.</p></li>
+   
+   <li><p>If the <var title="">event name</var> buffer has a value
+   other than the empty string, change the type of the newly created
+   event to equal the value of the <var title="">event name</var>
+   buffer.</p></li>
 
-  </dl>
+   <li><p>Set the <var title="">data</var> buffer and the <var
+   title="">event name</var> buffer to the empty string.</p></li>
 
-  <p>Other fields depend on the interface specified (or possibly
-  implied) by the <code title="">Class</code> field. If the specified
-  interface has an attribute that exactly matches the name of the
-  field, and the value of the field can be converted (using the type
-  conversions defined in ECMAScript) to the type of the attribute,
-  then it must be used. Any attributes (other than the
-  <code>Event</code> interface attributes) that do not have matching
-  fields are initialised to zero, null, false, or the empty
-  string.</p>
+   <li><p>Dispatch the newly created event at the
+   <code>RemoteEventTarget</code> object to which the event stream is
+   registered.</p></li>
 
-  <div class="example">
-   <p>For example:</p>
-   <pre>Event: click
-Class: MouseEvent
-button: 2</pre>
-   <p>...would result in a 'click' event using the
-   <code>MouseEvent</code> interface that has <code>button</code> set
-   to <code title="">2</code> but <code>screenX</code>,
-   <code>screenY</code>, etc, set to 0, false, or null as
-   appropriate.</p>
-  </div>
+  </ol>
 
-  <p>If a field does not match any of the attributes on the event, it
-  must be ignored.</p>
 
   <div class="example">
-   <p>For example:</p>
-   <pre>Event: keypress
-Class: MouseEvent
-keyIdentifier: 0</pre>
-   <p>...would result in a <code>MouseEvent</code> event with its
-   fields all at their default values, with the event name being <code
-   title="">keypress</code>. The <code title="">keyIdentifier</code>
-   field would be ignored. (If the author had not included the <code
-   title="">Class</code> field explicitly, it would have just worked,
-   since the class would have defaulted as described above.)</p>
-  </div>
 
-  <p>Once a blank line or the end of the file is reached, an event of
-  the type and namespace given by the <code title="">Event</code> and
-  <code>Namespace</code> fields respectively must be synthesized and
-  dispatched to the appropriate node as described by the fields
-  above. No event must be dispatched until a blank line has been
-  received or the end of the file reached.</p>
-
-  <p>The event must be dispatched as if using the DOM <code
-  title="">dispatchEvent()</code> method. Thus, if the <code
-  title="">Event</code> field was omitted, leaving the name as the
-  empty string, or if the name had invalid characters, then the
-  dispatching of the event fails.</p>
-
-  <p>Events fired from event sources do not have user-agent default
-  actions.</p>
-
-  <div class="example">
-
    <p>The following event stream, once followed by a blank line:</p>
    <pre>data: YHOO
 data: -2
@@ -33268,10 +33149,10 @@
    <p>...would cause an event <code
    title="event-message">message</code> with the interface
    <code>MessageEvent</code> to be dispatched on the
-   <code>event-source</code> element, which would then bubble up the
-   DOM, and whose <code title="dom-MessageEvent-data">data</code>
-   attribute would contain the string <code>YHOO\n-2\n10</code> (where
-   <code>\n</code> again represents a newline).</p>
+   <code>event-source</code> element, whose <code
+   title="dom-MessageEvent-data">data</code> attribute would contain
+   the string <code>YHOO\n-2\n10</code> (where <code>\n</code>
+   represents a newline).</p>
 
    <p>This could be used as follows:
    <pre>&lt;event-source src="http://stocks.example.com/ticker.php"
@@ -33284,38 +33165,69 @@
 
   <div class="example">
 
-   <p>The following stream contains four blocks and therefore fires
-   four events. The first block has just a comment, and will fire a
-   <code title="event-message">message</code> event with all the
-   fields set to the empty string or null. The second block has two
-   fields with names "load" and "Target" respectively; since there is
-   no "<code title="">load</code>" member on the
-   <code>MessageEvent</code> object that field is ignored, leaving the
-   event as a second <code title="event-message">message</code> event
-   with all the fields set to the empty string or null, but this time
-   the event is targetted at an element with ID "image1". The third
-   block is empty (no lines between two blank lines), and the fourth
-   block has only two comments, so they both yet again fire <code
-   title="event-message">message</code> events with all the fields set
-   to the empty string or null.</p>
+   <p>The following stream contains four blocks. The first block has
+   just a comment, and will fire nothing. The second block has two
+   fields with names "data" and "id" respectively; an event will be
+   fired for this block, with the data "first event", and will then
+   set the last event ID to "1" so that if the connection died between
+   this block and the next, the server would be sent a <code
+   title="">Last-Event-ID</code> header with the value "1". The third
+   block fires an event with data "second event", and also has an "id"
+   field, this time with no value, which resets the last event ID to
+   the empty string (meaning no code title="">Last-Event-ID</code>
+   header will now be sent in the event of a reconnection being
+   attempted). Finally the last block just fires an event with the
+   data "third event". Note that the last block doesn't have to end
+   with a blank line, the end of the stream is enough to trigger the
+   dispatch of the last event.</p>
 
-   <pre>; test
+   <pre>: test stream
 
-load
-Target: #image1
+data: first event
+id: 1
 
+data: second event
+id
 
-; if any more events follow this block, they will not be affected by
-; the "Target" and "load" fields above.
-</pre>
+data: third event</pre>
   </div>
 
+  <div class="example">
 
+   <p>The following stream fires just one event:</p>
+
+   <pre>data
+
+data
+data
+
+data:</pre>
+
+   <p>The first and last blocks do nothing, since they do not contain
+   any actual data (the <var title="">data</var> buffer remains at the
+   empty string, and so nothing gets dispatched). The middle block
+   fires an event with the data set to a single newline character.</p>
+  </div>
+
+  <div class="example">
+
+   <p>The following stream fires two identical events:</p>
+
+   <pre>data:test
+
+data:&nbsp;test</pre>
+
+   <p>This is because the space after the colon is ignored if
+   present.</p>
+
+  </div>
+
+
   <h4>Notes</h4>
 
   <p>Legacy proxy servers are known to, in certain cases, drop HTTP
   connections after a short timeout. To protect against such proxy
-  servers, authors can include a comment line (one starting with a ';'
+  servers, authors can include a comment line (one starting with a ':'
   character) every 15 seconds or so.</p>
 
   <p>Authors wishing to relate event source connections to each other
@@ -34288,7 +34200,7 @@
 
     <p>Create an event that uses the <code>MessageEvent</code>
     interface, with the event name <code
-    title="event-message">message</code>, which bubbles, is
+    title="event-message">message</code>, which does not bubble, is
     cancelable, and has no default action. The <code
     title="dom-MessageEvent-data">data</code> attribute must be set to
     the value passed as the <var title="">message</var> argument to




More information about the Commit-Watchers mailing list