Changeset 52891 in webkit


Ignore:
Timestamp:
Jan 6, 2010 6:20:02 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-06 Adam Bergkvist <adam.bergkvist@ericsson.com>

Reviewed by Darin Adler.

Modified EventSource event-stream parser to support a single CR as line ending.
Updated test accordingly.
https://bugs.webkit.org/show_bug.cgi?id=33207

  • 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-01-06 Adam Bergkvist <adam.bergkvist@ericsson.com>

Reviewed by Darin Adler.

Modified EventSource event-stream parser to support a single CR as line ending.
https://bugs.webkit.org/show_bug.cgi?id=33207

  • page/EventSource.cpp: (WebCore::EventSource::EventSource): (WebCore::EventSource::parseEventStream):
  • page/EventSource.h:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r52889 r52891  
     12010-01-06  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Modified EventSource event-stream parser to support a single CR as line ending.
     6        Updated test accordingly.
     7        https://bugs.webkit.org/show_bug.cgi?id=33207
     8
     9        * http/tests/eventsource/eventsource-parse-event-stream-expected.txt:
     10        * http/tests/eventsource/eventsource-parse-event-stream.html:
     11        * http/tests/eventsource/resources/event-stream.php:
     12
    1132010-01-06  Dan Bernstein  <mitz@apple.com>
    214
  • trunk/LayoutTests/http/tests/eventsource/eventsource-parse-event-stream-expected.txt

    r47323 r52891  
    99PASS: got open event from server
    1010PASS: received event and the event name has been reset
    11 PASS: received event with data that contains a colon and a carriage return
     11PASS: received event with data that contains a colon
    1212DONE
    1313
  • trunk/LayoutTests/http/tests/eventsource/eventsource-parse-event-stream.html

    r47323 r52891  
    5050            break;
    5151        case 6:
    52             if (evt.data == "a line ending with crlf\na line with a : (colon)\na line with a \r (carriage return)")
    53                 log("PASS: received event with data that contains a colon and a carriage return");
     52            if (evt.data == "a line ending with crlf\na line with a : (colon)\na line ending with cr");
     53                log("PASS: received event with data that contains a colon");
    5454            break;
    5555        default:
  • trunk/LayoutTests/http/tests/eventsource/resources/event-stream.php

    r47323 r52891  
    3939<?php echo "data: a line ending with crlf\r\n"; ?>
    4040data: a line with a : (colon)
    41 <?php echo "data: a line with a \r (carriage return)\n"; ?>
     41<?php echo "data: a line ending with cr\r"; ?>
    4242
    4343retry: 10000
  • trunk/WebCore/ChangeLog

    r52890 r52891  
     12010-01-06  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Modified EventSource event-stream parser to support a single CR as line ending.
     6        https://bugs.webkit.org/show_bug.cgi?id=33207
     7
     8        * page/EventSource.cpp:
     9        (WebCore::EventSource::EventSource):
     10        (WebCore::EventSource::parseEventStream):
     11        * page/EventSource.h:
     12
    1132010-01-06  Joanmarie Diggs  <joanmarie.diggs@gmail.com>
    214
  • trunk/WebCore/page/EventSource.cpp

    r49214 r52891  
    5858    , m_state(CONNECTING)
    5959    , m_reconnectTimer(this, &EventSource::reconnectTimerFired)
     60    , m_discardTrailingNewline(false)
    6061    , m_failSilently(false)
    6162    , m_requestInFlight(false)
     
    211212    unsigned int bufPos = 0;
    212213    unsigned int bufSize = m_receiveBuf.size();
    213     for (;;) {
     214    while (bufPos < bufSize) {
     215        if (m_discardTrailingNewline) {
     216            if (m_receiveBuf[bufPos] == '\n')
     217                bufPos++;
     218            m_discardTrailingNewline = false;
     219        }
     220
    214221        int lineLength = -1;
    215222        int fieldLength = -1;
    216         int carriageReturn = 0;
    217223        for (unsigned int i = bufPos; lineLength < 0 && i < bufSize; i++) {
    218224            switch (m_receiveBuf[i]) {
     
    221227                    fieldLength = i - bufPos;
    222228                break;
     229            case '\r':
     230                m_discardTrailingNewline = true;
    223231            case '\n':
    224                 if (i > bufPos && m_receiveBuf[i - 1] == '\r') {
    225                     carriageReturn++;
    226                     i--;
    227                 }
    228232                lineLength = i - bufPos;
    229233                break;
     
    235239
    236240        parseEventStreamLine(bufPos, fieldLength, lineLength);
    237         bufPos += lineLength + carriageReturn + 1;
     241        bufPos += lineLength + 1;
    238242    }
    239243
  • trunk/WebCore/page/EventSource.h

    r51473 r52891  
    115115        Timer<EventSource> m_reconnectTimer;
    116116        Vector<UChar> m_receiveBuf;
     117        bool m_discardTrailingNewline;
    117118        bool m_failSilently;
    118119        bool m_requestInFlight;
Note: See TracChangeset for help on using the changeset viewer.