Closed
Bug 710546
Opened 14 years ago
Closed 13 years ago
Server sent events Once the end of the file is reached, any pending data must be discarded
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: vic99999, Assigned: wfernandom2004)
Details
Attachments
(1 file, 1 obsolete file)
13.18 KB,
patch
|
smaug
:
review+
smaug
:
checkin+
|
Details | Diff | Splinter Review |
User Agent: Opera/9.80 (Windows NT 6.0; U; Edition Next; ru) Presto/2.10.238 Version/12.00
Steps to reproduce:
according to latest spec:
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.) - see http://dev.w3.org/html5/eventsource/
Actual results:
var es = new EventSource('events.php');
es.onmessage = function (e) {
alert(e.data + ' ' + e.lastEventId);// Firefox alerts "data0 123"
};
events.php:
echo "id: 123\n";
echo "data: data0";
exit();
Expected results:
If the file ends in the middle of an event, before the final empty line, the incomplete event is not dispatched.
Also the last id field value received should be stored in a buffer and set as the EventSource's lastEventId only when the event is actually dispatched - see http://www.w3.org/Bugs/Public/show_bug.cgi?id=13761
Assignee | ||
Comment 1•13 years ago
|
||
Just a commentary for clarifying future questions. According to spec:
>> event = *( comment / field ) end-of-line
>> field = 1*name-char [ colon [ space ] *any-char ] end-of-line
>> end-of-line = ( cr lf / cr / lf )
>>
>> If the file ends in the middle of an event, before the final empty line, the incomplete
>> event is not dispatched.
So, for instance, the following code won't dispatch an event either:
>> echo "data: data0\r";
>> exit;
But this one will:
>> echo "data: data0\r\r";
>> exit;
Assignee: nobody → wfernandom2004
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Updated•13 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•13 years ago
|
||
Attachment #617246 -
Flags: review?
Assignee | ||
Comment 3•13 years ago
|
||
Comment on attachment 617246 [details] [diff] [review]
v1
Olli, just a comment, I've removed the test which was testing an invalid NCName char in the event field name because it has become obsolete due changes in the spec.
Attachment #617246 -
Flags: review? → review?(bugs)
Assignee | ||
Comment 4•13 years ago
|
||
Comment 5•13 years ago
|
||
(Hopefully reviewing this tomorrow.)
Comment 6•13 years ago
|
||
(In reply to Wellington Fernando de Macedo from comment #1)
> Just a commentary for clarifying future questions. According to spec:
> >> event = *( comment / field ) end-of-line
> >> field = 1*name-char [ colon [ space ] *any-char ] end-of-line
> >> end-of-line = ( cr lf / cr / lf )
> >>
> >> If the file ends in the middle of an event, before the final empty line, the incomplete
> >> event is not dispatched.
>
> So, for instance, the following code won't dispatch an event either:
> >> echo "data: data0\r";
> >> exit;
> But this one will:
> >> echo "data: data0\r\r";
> >> exit;
Er, what. Do we need two new lines? that looks like a spec bug to me.
Comment 7•13 years ago
|
||
Comment on attachment 617246 [details] [diff] [review]
v1
Actually, perhaps it is ok.
Have you tested other browsers?
Attachment #617246 -
Flags: review?(bugs) → review+
Comment 8•13 years ago
|
||
Comment on attachment 617246 [details] [diff] [review]
v1
>+++ b/content/base/test/badContentType.eventsource
>@@ -1,3 +1,5 @@
> retry:500
> event: message
> data: 1
>+
>+
Actually, why do you need 2 empty lines? Shouldn't 1 be enough
Assignee | ||
Comment 9•13 years ago
|
||
>> Actually, why do you need 2 empty lines? Shouldn't 1 be enough
Actually, I think 1 empty line would be enough. But, according to the spec:
1. event = *( comment / field ) end-of-line
2. field = 1*name-char [ colon [ space ] *any-char ] end-of-line
Hence:
event = 1*name-char [ colon [ space ] *any-char ] end-of-line end-of-line
Also:
>> If the file ends in the *middle of an event*, *before the final* empty line,
>> the incomplete event is not dispatched.
>> Have you tested other browsers?
No, unfortunately I didn't. Anyway, if they dispatch with just one empty line then either the spec needs to be fixed or the other browsers implementations need to be fixed.
Comment 10•13 years ago
|
||
But you have the end-of-line after data: 1 and then 2 end-of-lines, so totally 3.
I think 2 should be enough, per spec
Assignee | ||
Comment 11•13 years ago
|
||
Humm, I think there are 2 end-of-lines, not three:
> data: 1 LF
>+ LF
>+ EOF
isn't it?
Comment 12•13 years ago
|
||
Um, right, silly me.
I interpreted the diff in a wrong way.
Reporter | ||
Comment 13•13 years ago
|
||
any updates?
Assignee | ||
Comment 14•13 years ago
|
||
It is already done. Perhaps it needs just to be update to the trunk.
Comment 15•13 years ago
|
||
Argh, this wasn't just pushed to m-c. My bad.
Wellington, want to update the patch to work with trunk? If you don't have time, I can do it.
Assignee | ||
Comment 16•13 years ago
|
||
Ok, no problem Olli. I'll update it tomorrow and upload again here.
Comment 17•13 years ago
|
||
Thanks!
Assignee | ||
Comment 18•13 years ago
|
||
Attachment #617246 -
Attachment is obsolete: true
Attachment #704732 -
Flags: review?(bugs)
Attachment #704732 -
Flags: checkin?(bugs)
Comment 19•13 years ago
|
||
Comment on attachment 704732 [details] [diff] [review]
v1 updated
tree is closed atm, so can push this right now.
Attachment #704732 -
Flags: review?(bugs) → review+
Reporter | ||
Comment 20•13 years ago
|
||
fine, thank you
Comment 21•13 years ago
|
||
Tryserver https://tbpl.mozilla.org/?tree=Try&rev=e1a689a9390b
Waiting for the results before pushing.
Comment 22•13 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Updated•13 years ago
|
Attachment #704732 -
Flags: checkin?(bugs) → checkin+
You need to log in
before you can comment on or make changes to this bug.
Description
•