Changeset 56035 in webkit


Ignore:
Timestamp:
Mar 15, 2010 9:58:55 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-15 Adam Bergkvist <adam.bergkvist@ericsson.com>

Reviewed by Adam Barth.

According to the updated specification, a data field should always
result in a newline character being appended to the data buffer
regardless if the data buffer contains any data or not. However, upon
event dispatch, the last newline will be removed. This differs from an
older version of the specification where a newline character was
appended before the data value only if the buffer already contained
data. As a result, EventSource now supports receiving events with empty
data or newline characters only. Updated test accordingly.
https://bugs.webkit.org/show_bug.cgi?id=33210

  • http/tests/eventsource/eventsource-parse-event-stream-expected.txt:
  • http/tests/eventsource/eventsource-parse-event-stream.html:
  • http/tests/eventsource/resources/event-stream.php:

2010-03-15 Adam Bergkvist <adam.bergkvist@ericsson.com>

Reviewed by Adam Barth.

According to the updated specification, a data field should always
result in a newline character being appended to the data buffer
regardless if the data buffer contains any data or not. However, upon
event dispatch, the last newline will be removed. This differs from an
older version of the specification where a newline character was
appended before the data value only if the buffer already contained
data. As a result, EventSource now supports receiving events with empty
data or newline characters only.
https://bugs.webkit.org/show_bug.cgi?id=33210

  • page/EventSource.cpp: (WebCore::EventSource::parseEventStreamLine):
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r56033 r56035  
     12010-03-15  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        Reviewed by Adam Barth.
     4
     5        According to the updated specification, a data field should always
     6        result in a newline character being appended to the data buffer
     7        regardless if the data buffer contains any data or not. However, upon
     8        event dispatch, the last newline will be removed. This differs from an
     9        older version of the specification where a newline character was
     10        appended before the data value only if the buffer already contained
     11        data. As a result, EventSource now supports receiving events with empty
     12        data or newline characters only. Updated test accordingly.
     13        https://bugs.webkit.org/show_bug.cgi?id=33210
     14
     15        * http/tests/eventsource/eventsource-parse-event-stream-expected.txt:
     16        * http/tests/eventsource/eventsource-parse-event-stream.html:
     17        * http/tests/eventsource/resources/event-stream.php:
     18
    1192010-03-15  Valters Svabe  <vsvabe@gmail.com>
    220
  • trunk/LayoutTests/http/tests/eventsource/eventsource-parse-event-stream-expected.txt

    r52891 r56035  
    22
    33PASS: got open event
     4PASS: received event with two newlines
    45PASS: received event with data "simple"
    56PASS: received event with data spanning multiple lines
  • trunk/LayoutTests/http/tests/eventsource/eventsource-parse-event-stream.html

    r52891 r56035  
    1313}
    1414
    15 var count = 0;
     15var count = -1;
    1616var es = new EventSource("resources/event-stream.php");
    1717
     
    2525es.onmessage = function (evt) {
    2626    switch(count++) {
     27        case -1:
     28            if (evt.data == "\n\n")
     29                log("PASS: received event with two newlines");
     30            break;
    2731        case 0:
    2832            if (evt.data == "simple")
  • trunk/LayoutTests/http/tests/eventsource/resources/event-stream.php

    r52891 r56035  
    1313data:
    1414data
    15 : no dispatch since data buffer is empty
     15: dispatch event with two newlines
    1616
    1717data: simple
  • trunk/WebCore/ChangeLog

    r56033 r56035  
     12010-03-15  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        Reviewed by Adam Barth.
     4
     5        According to the updated specification, a data field should always
     6        result in a newline character being appended to the data buffer
     7        regardless if the data buffer contains any data or not. However, upon
     8        event dispatch, the last newline will be removed. This differs from an
     9        older version of the specification where a newline character was
     10        appended before the data value only if the buffer already contained
     11        data. As a result, EventSource now supports receiving events with empty
     12        data or newline characters only.
     13        https://bugs.webkit.org/show_bug.cgi?id=33210
     14
     15        * page/EventSource.cpp:
     16        (WebCore::EventSource::parseEventStreamLine):
     17
    1182010-03-15  Valters Svabe  <vsvabe@gmail.com>
    219
  • trunk/WebCore/page/EventSource.cpp

    r52891 r56035  
    251251{
    252252    if (!lineLength) {
    253         if (!m_data.isEmpty())
     253        if (!m_data.isEmpty()) {
     254            m_data.removeLast();
    254255            dispatchEvent(createMessageEvent());
     256        }
    255257        if (!m_eventName.isEmpty())
    256258            m_eventName = "";
     
    270272
    271273        if (field == "data") {
    272             if (m_data.size() > 0)
    273                 m_data.append('\n');
    274274            if (valueLength)
    275275                m_data.append(&m_receiveBuf[bufPos], valueLength);
     276            m_data.append('\n');
    276277        } else if (field == "event")
    277278            m_eventName = valueLength ? String(&m_receiveBuf[bufPos], valueLength) : "";
Note: See TracChangeset for help on using the changeset viewer.