Skip to content

Commit

Permalink
[giow] (1) Change text/event-stream to drop final events not followed…
Browse files Browse the repository at this point in the history
… by a blank line, since otherwise interrupted streams would fire incomplete events.

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=13071

git-svn-id: http://svn.whatwg.org/webapps@6371 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Aug 4, 2011
1 parent 22cb282 commit 9a8bf69
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 35 deletions.
45 changes: 26 additions & 19 deletions complete.html
Expand Up @@ -79840,8 +79840,7 @@ <h4 id=parsing-an-event-stream><span class=secno>11.2.4 </span>Parsing an event
event = *( comment / field ) end-of-line
comment = colon *any-char end-of-line
field = 1*name-char [ colon [ space ] *any-char ] end-of-line
end-of-line = ( cr lf / cr / lf / eof )
eof = &lt; matches repeatedly at the end of the stream &gt;
end-of-line = ( cr lf / cr / lf )

; characters
lf = %x000A ; U+000A LINE FEED (LF)
Expand Down Expand Up @@ -79934,11 +79933,11 @@ <h4 id=event-stream-interpretation><span class=secno>11.2.5 </span>Interpreting

</dd>

</dl><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>

</dl><p>Once the end of the file is reached, any pending data must be
discarded. (If the file ends in the middle of an event, before the
final empty line, the incomplete event is not dispatched.)</p>

<p id=processField>The steps to <dfn title="">process the
<hr><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>
Expand Down Expand Up @@ -80089,10 +80088,11 @@ <h4 id=event-stream-interpretation><span class=secno>11.2.5 </span>Interpreting
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=http-last-event-id><a href=#last-event-id>Last-Event-ID</a></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 "&nbsp;third&nbsp;event"
(with a single leading space character). 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>
last block just fires an event with the data
"&nbsp;third&nbsp;event" (with a single leading space character).
Note that the last still has to end with a blank line, the end of
the stream is not enough to trigger the dispatch of the last
event.</p>

<pre>: test stream

Expand All @@ -80102,12 +80102,13 @@ <h4 id=event-stream-interpretation><span class=secno>11.2.5 </span>Interpreting
data:second event
id

data:&nbsp;&nbsp;third event</pre>
data:&nbsp;&nbsp;third event
</pre>
</div>

<div class=example>

<p>The following stream fires three events:</p>
<p>The following stream fires two events:</p>

<pre>data

Expand All @@ -80116,9 +80117,11 @@ <h4 id=event-stream-interpretation><span class=secno>11.2.5 </span>Interpreting

data:</pre>

<p>The first and last blocks fire events with the data set to the
empty string. The middle block fires an event with the data set to
a single newline character.</p>
<p>The first block fires events with the data set to the empty
string, as would the last block if it was followed by a blank line.
The middle block fires an event with the data set to a single
newline character. The last block is discarded because it is not
followed by a blank line.</p>

</div>

Expand All @@ -80128,7 +80131,8 @@ <h4 id=event-stream-interpretation><span class=secno>11.2.5 </span>Interpreting

<pre>data:test

data:&nbsp;test</pre>
data:&nbsp;test
</pre>

<p>This is because the space after the colon is ignored if
present.</p>
Expand Down Expand Up @@ -80267,15 +80271,18 @@ <h5 id=text/event-stream><span class=secno>11.2.9.1 </span><dfn><code>text/event
<dt>Required parameters:</dt>
<dd>No parameters</dd>
<dt>Optional parameters:</dt>
<dt>
</dt><dl><dt><code title="">charset</code></dt>
<dd>
<dl><dt><code title="">charset</code></dt>
<dd>

<p>The <code title="">charset</code> parameter may be provided.
The parameter's value must be "<code title="">utf-8</code>".
This parameter serves no purpose; it is only allowed for
compatibility with legacy servers.</p>

</dd>
</dl><dt>Encoding considerations:</dt>
</dl></dd>
<dt>Encoding considerations:</dt>
<dd>Always UTF-8.</dd>
<dt>Security considerations:</dt>
<dd>
Expand Down
39 changes: 23 additions & 16 deletions source
Expand Up @@ -90372,8 +90372,7 @@ interface <dfn>EventSource</dfn> {
event = *( comment / field ) end-of-line
comment = colon *any-char end-of-line
field = 1*name-char [ colon [ space ] *any-char ] end-of-line
end-of-line = ( cr lf / cr / lf / eof )
eof = &lt; matches repeatedly at the end of the stream >
end-of-line = ( cr lf / cr / lf )

; characters
lf = %x000A ; U+000A LINE FEED (LF)
Expand Down Expand Up @@ -90473,10 +90472,11 @@ any-char = %x0000-0009 / %x000B-000C / %x000E-10FFFF

</dl>

<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>
<p>Once the end of the file is reached, any pending data must be
discarded. (If the file ends in the middle of an event, before the
final empty line, the incomplete event is not dispatched.)</p>

<hr>

<p id="processField">The steps to <dfn title="">process the
field</dfn> given a field name and a field value depend on the field
Expand Down Expand Up @@ -90653,10 +90653,11 @@ stocks.onmessage = function (event) {
the last event ID to the empty string (meaning no <code
title="http-last-event-id">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 "&nbsp;third&nbsp;event"
(with a single leading space character). 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>
last block just fires an event with the data
"&nbsp;third&nbsp;event" (with a single leading space character).
Note that the last still has to end with a blank line, the end of
the stream is not enough to trigger the dispatch of the last
event.</p>

<pre>: test stream

Expand All @@ -90666,12 +90667,13 @@ id: 1
data:second event
id

data:&nbsp;&nbsp;third event</pre>
data:&nbsp;&nbsp;third event
</pre>
</div>

<div class="example">

<p>The following stream fires three events:</p>
<p>The following stream fires two events:</p>

<pre>data

Expand All @@ -90680,9 +90682,11 @@ data

data:</pre>

<p>The first and last blocks fire events with the data set to the
empty string. The middle block fires an event with the data set to
a single newline character.</p>
<p>The first block fires events with the data set to the empty
string, as would the last block if it was followed by a blank line.
The middle block fires an event with the data set to a single
newline character. The last block is discarded because it is not
followed by a blank line.</p>

</div>

Expand All @@ -90692,7 +90696,8 @@ data:</pre>

<pre>data:test

data:&nbsp;test</pre>
data:&nbsp;test
</pre>

<p>This is because the space after the colon is ignored if
present.</p>
Expand Down Expand Up @@ -90846,14 +90851,16 @@ data:&nbsp;test</pre>
<dt>Required parameters:</dt>
<dd>No parameters</dd>
<dt>Optional parameters:</dt>
<dt>
<dd>
<dl>
<dt><code title="">charset</code></dt>
<dd>

<p>The <code title="">charset</code> parameter may be provided.
The parameter's value must be "<code title="">utf-8</code>".
This parameter serves no purpose; it is only allowed for
compatibility with legacy servers.</p>

</dd>
</dl>
</dd>
Expand Down

0 comments on commit 9a8bf69

Please sign in to comment.