Commit 39adec95 authored by eric@webkit.org's avatar eric@webkit.org

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:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52891 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 10e02f83
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 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
......@@ -8,6 +8,6 @@ PASS: received event and lastEventId is still "1"
PASS: received event and lastEventId has been cleared
PASS: got open event from server
PASS: received event and the event name has been reset
PASS: received event with data that contains a colon and a carriage return
PASS: received event with data that contains a colon
DONE
......@@ -49,8 +49,8 @@ es.onmessage = function (evt) {
log("PASS: received event and the event name has been reset");
break;
case 6:
if (evt.data == "a line ending with crlf\na line with a : (colon)\na line with a \r (carriage return)")
log("PASS: received event with data that contains a colon and a carriage return");
if (evt.data == "a line ending with crlf\na line with a : (colon)\na line ending with cr");
log("PASS: received event with data that contains a colon");
break;
default:
log("FAIL: got unexpected event");
......
......@@ -38,7 +38,7 @@ ta: a message event with the name "message"
<?php echo "data: a line ending with crlf\r\n"; ?>
data: a line with a : (colon)
<?php echo "data: a line with a \r (carriage return)\n"; ?>
<?php echo "data: a line ending with cr\r"; ?>
retry: 10000
: reconnection time set to 10 seconds
......
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:
2010-01-06 Joanmarie Diggs <joanmarie.diggs@gmail.com>
Reviewed by Xan Lopez.
......@@ -57,6 +57,7 @@ EventSource::EventSource(const String& url, ScriptExecutionContext* context, Exc
: ActiveDOMObject(context, this)
, m_state(CONNECTING)
, m_reconnectTimer(this, &EventSource::reconnectTimerFired)
, m_discardTrailingNewline(false)
, m_failSilently(false)
, m_requestInFlight(false)
, m_reconnectDelay(defaultReconnectDelay)
......@@ -210,21 +211,24 @@ void EventSource::parseEventStream()
{
unsigned int bufPos = 0;
unsigned int bufSize = m_receiveBuf.size();
for (;;) {
while (bufPos < bufSize) {
if (m_discardTrailingNewline) {
if (m_receiveBuf[bufPos] == '\n')
bufPos++;
m_discardTrailingNewline = false;
}
int lineLength = -1;
int fieldLength = -1;
int carriageReturn = 0;
for (unsigned int i = bufPos; lineLength < 0 && i < bufSize; i++) {
switch (m_receiveBuf[i]) {
case ':':
if (fieldLength < 0)
fieldLength = i - bufPos;
break;
case '\r':
m_discardTrailingNewline = true;
case '\n':
if (i > bufPos && m_receiveBuf[i - 1] == '\r') {
carriageReturn++;
i--;
}
lineLength = i - bufPos;
break;
}
......@@ -234,7 +238,7 @@ void EventSource::parseEventStream()
break;
parseEventStreamLine(bufPos, fieldLength, lineLength);
bufPos += lineLength + carriageReturn + 1;
bufPos += lineLength + 1;
}
if (bufPos == bufSize)
......
......@@ -114,6 +114,7 @@ namespace WebCore {
RefPtr<ThreadableLoader> m_loader;
Timer<EventSource> m_reconnectTimer;
Vector<UChar> m_receiveBuf;
bool m_discardTrailingNewline;
bool m_failSilently;
bool m_requestInFlight;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment