diff --git a/ServerSentEvents/README.txt b/ServerSentEvents/README.txt new file mode 100644 index 00000000000000..4a9b3b93fcdc4c --- /dev/null +++ b/ServerSentEvents/README.txt @@ -0,0 +1,3 @@ +EventSource tests require the use of a server on the same domain. + +sse.js contains the server-side code to be used on a node.js server (http://nodejs.org). \ No newline at end of file diff --git a/ServerSentEvents/absolute-url.html b/ServerSentEvents/absolute-url.html new file mode 100644 index 00000000000000..18dc8b81a57378 --- /dev/null +++ b/ServerSentEvents/absolute-url.html @@ -0,0 +1,34 @@ + + + + The url attribute must return the absolute URL that resulted from resolving the value that was passed to the constructor: + + + + + + + + + + +

The url attribute must return the absolute URL that resulted from resolving the value that was passed to the constructor:

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/accept-header-include-text-event-stream.html b/ServerSentEvents/accept-header-include-text-event-stream.html new file mode 100644 index 00000000000000..238fe7e65e9cb7 --- /dev/null +++ b/ServerSentEvents/accept-header-include-text-event-stream.html @@ -0,0 +1,39 @@ + + + + For HTTP connections, the Accept header may be included; if included, it must contain only formats of event framing that are supported by the user agent (one of which must be text/event-stream, as described below): + + + + + + + + + + +

For HTTP connections, the Accept header may be included; if included, it must contain only formats of event framing that are supported by the user agent (one of which must be text/event-stream, as described below):

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/event-type-eventsource.html b/ServerSentEvents/event-type-eventsource.html new file mode 100644 index 00000000000000..b4bf48c2f548d5 --- /dev/null +++ b/ServerSentEvents/event-type-eventsource.html @@ -0,0 +1,23 @@ + + + + When the EventSource() constructor is invoked, the UA must run these steps: Create a new EventSource object: + + + + + + + + + + +

When the EventSource() constructor is invoked, the UA must run these steps: Create a new EventSource object:

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/eventsource-aborted-after-close-method.html b/ServerSentEvents/eventsource-aborted-after-close-method.html new file mode 100644 index 00000000000000..d9d28cb0b1a4dc --- /dev/null +++ b/ServerSentEvents/eventsource-aborted-after-close-method.html @@ -0,0 +1,39 @@ + + + + The close() method must abort any instances of the fetch algorithm started for this EventSource object, and must set the readyState attribute to CLOSED: + + + + + + + + + + +

The close() method must abort any instances of the fetch algorithm started for this EventSource object, and must set the readyState attribute to CLOSED:

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/field-name-data.html b/ServerSentEvents/field-name-data.html new file mode 100644 index 00000000000000..8c138a3429a16f --- /dev/null +++ b/ServerSentEvents/field-name-data.html @@ -0,0 +1,54 @@ + + + + The steps to process the field given a field name and a field value depend on the field name: The field name is "data": + + + + + + + + + + +

The steps to process the field given a field name and a field value depend on the field name: The field name is "data":

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/field-name-event.html b/ServerSentEvents/field-name-event.html new file mode 100644 index 00000000000000..025a99324d8faf --- /dev/null +++ b/ServerSentEvents/field-name-event.html @@ -0,0 +1,40 @@ + + + + The steps to process the field given a field name and a field value depend on the field name: The field name is "event": + + + + + + + + + + +

The steps to process the field given a field name and a field value depend on the field name: The field name is "event":

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/field-name-id.html b/ServerSentEvents/field-name-id.html new file mode 100644 index 00000000000000..8b5ff54244c2e1 --- /dev/null +++ b/ServerSentEvents/field-name-id.html @@ -0,0 +1,48 @@ + + + + The steps to process the field given a field name and a field value depend on the field name: The field name is "id": + + + + + + + + + + +

The steps to process the field given a field name and a field value depend on the field name: The field name is "id":

+

waiting...

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/field-name-other.html b/ServerSentEvents/field-name-other.html new file mode 100644 index 00000000000000..da9703679c44f9 --- /dev/null +++ b/ServerSentEvents/field-name-other.html @@ -0,0 +1,45 @@ + + + + The steps to process the field given a field name and a field value depend on the field name: Other: + + + + + + + + + + +

The steps to process the field given a field name and a field value depend on the field name: Other:

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/field-name-retry.txt b/ServerSentEvents/field-name-retry.txt new file mode 100644 index 00000000000000..ad2ca1764066b6 --- /dev/null +++ b/ServerSentEvents/field-name-retry.txt @@ -0,0 +1,53 @@ + + + + The steps to process the field given a field name and a field value depend on the field name: The field name is "retry": + + + + + + + + + + +

The steps to process the field given a field name and a field value depend on the field name: The field name is "retry":

+

waiting...

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/line-contains-colon.html b/ServerSentEvents/line-contains-colon.html new file mode 100644 index 00000000000000..5f14eaade9d5ad --- /dev/null +++ b/ServerSentEvents/line-contains-colon.html @@ -0,0 +1,41 @@ + + + + Lines must be processed, in the order they are received, as follows: If the line contains a U+003A COLON character (:), collect the characters on the line before the first (:), and let field be that string, collect the characters on the line after the first (:), and let value be that string. If value starts with a U+0020 SPACE character, remove it from value: + + + + + + + + + + +

Lines must be processed, in the order they are received, as follows: If the line contains a U+003A COLON character (:), collect the characters on the line before the first (:), and let field be that string, collect the characters on the line after the first (:), and let value be that string. If value starts with a U+0020 SPACE character, remove it from value:

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/line-starts-with-colon.html b/ServerSentEvents/line-starts-with-colon.html new file mode 100644 index 00000000000000..c2fd2337488c3d --- /dev/null +++ b/ServerSentEvents/line-starts-with-colon.html @@ -0,0 +1,39 @@ + + + + Lines must be processed, in the order they are received, as follows: If the line starts with a U+003A COLON character, ignore the line: + + + + + + + + + + +

Lines must be processed, in the order they are received, as follows: If the line starts with a U+003A COLON character, ignore the line:

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/onopen-onmessage-onerror-support.html b/ServerSentEvents/onopen-onmessage-onerror-support.html new file mode 100644 index 00000000000000..9fdae64d996ef0 --- /dev/null +++ b/ServerSentEvents/onopen-onmessage-onerror-support.html @@ -0,0 +1,39 @@ + + + + The event handlers (onopen, onmessage, onerror) must be supported, as IDL attributes, by all objects implementing the EventSource interface: + + + + + + + + + + +

The event handlers (onopen, onmessage, onerror) must be supported, as IDL attributes, by all objects implementing the EventSource interface:

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/readystate-each-state-connection.html b/ServerSentEvents/readystate-each-state-connection.html new file mode 100644 index 00000000000000..103b0fab25de14 --- /dev/null +++ b/ServerSentEvents/readystate-each-state-connection.html @@ -0,0 +1,44 @@ + + + + The readyState attribute represents the state of the connection. It can have the following values: 0 (CONNECTING), 1 (OPEN), 2 (CLOSED): + + + + + + + + + + +

The readyState attribute represents the state of the connection. It can have the following values: 0 (CONNECTING), 1 (OPEN), 2 (CLOSED):

+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/resolve-url-argument.html b/ServerSentEvents/resolve-url-argument.html new file mode 100644 index 00000000000000..7677218a9fe35e --- /dev/null +++ b/ServerSentEvents/resolve-url-argument.html @@ -0,0 +1,32 @@ + + + + + When the EventSource() constructor is invoked, the UA must run these steps: Resolve the URL specified in the first argument: + + + + + + + + + +

When the EventSource() constructor is invoked, the UA must run these steps: Resolve the URL specified in the first argument:

+ +
+
+ + + + \ No newline at end of file diff --git a/ServerSentEvents/sse.js b/ServerSentEvents/sse.js new file mode 100644 index 00000000000000..6d6e30b365b174 --- /dev/null +++ b/ServerSentEvents/sse.js @@ -0,0 +1,105 @@ +// Chargement des modules +var http = require('http'); +var sys = require('sys'); +var fs = require('fs'); + +// Creation du serveur d'écoute sur le port 8000 +http.createServer(function(req, res) { + + console.log(req.url); + console.log((req.url).indexOf("t00")); + console.log(req.headers.accept); + console.log(__dirname + req.url); + console.log((req.url).substr(3)); + + //debugHeaders(req); + //* + if (req.headers.accept && req.headers.accept == 'text/event-stream') { + if (req.url.indexOf("t00") != -1) { + sendSSE(req, res); + } else { + res.writeHead(404); + res.end(); + } + } + else { + if(req.url != "/favicon.ico"){ + res.writeHead(200, {'Content-Type': 'text/html'}); + res.write(fs.readFileSync(__dirname + req.url+".html")); + res.end(); + } + } + //*/ +}).listen(8000); + +function sendSSE(req, res) { + res.writeHead(200, { + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache', + 'Connection': 'keep-alive' + }); + + var id = (new Date()).toLocaleTimeString(); + head = req.headers.accept; + requrl = (req.url).substr(3); + // Sends a SSE every 5 seconds on a single connection. + setInterval(function() { + constructSSE(res, id, (new Date()).getMinutes()); + }, 5000); + constructSSE(res, id, (new Date()).getMinutes()); +} + +function constructSSE(res, id, data) { + res.write('id: ' + id + '\n'); + res.write("data: " + data + '\n'); + + switch(requrl){ + case "030": + res.write("data: " + head + '\n\n'); + break; + case "071": + res.write(':data: colon caracter\n\n'); + break; + case "072": + res.write('data: one space character\n'); + res.write('data: more spaces character\n\n'); + break; + case "074": + res.write('event: testevent\n'); + res.write('data: received\n\n'); + break; + case "075": + res.write('data: data buffer'); + res.write('data: no LF\n'); + res.write('data: one LF\n\n'); + res.write('data: two LF\n\n'); + break; + case "076": + res.write('id: ' +new Date().getSeconds()+ '\n'); + res.write('data: ' +data+ '\n\n'); + break; + case "077": + setInterval(function () { + sys.puts('Throwing error now.'); + throw new Error('User generated fault.'); + }, 1000); + res.write('retry: 2000\n\n'); + res.write("data: else\n\n"); + break; + case "078": + res.write('other: other\n'); + res.write('data: test\n\n'); + break; + default: + res.write('\n'); + break; + } +} + +function debugHeaders(req) { + sys.puts('URL: ' + req.url); + for (var key in req.headers) { + sys.puts(key + ': ' + req.headers[key]); + } + sys.puts('\n\n'); +} \ No newline at end of file diff --git a/ServerSentEvents/style.css b/ServerSentEvents/style.css new file mode 100644 index 00000000000000..ca6f639edf5b08 --- /dev/null +++ b/ServerSentEvents/style.css @@ -0,0 +1,13 @@ +q { font-style: italic } +li { padding-bottom: 1em; } +.fail { background-color: #f88; } +.pass { background-color: #8f8; } +.maybe { background-color: #aaf; } +.issue { background-color: #ff8; } +.na { background-color: #fcc; } +.spec-issue { color: red } +.warning { font-size: 150%; color: #f77 } +.important { font-size: 120%; font-weight: bold } +ul.toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; } +ul.toc li ul { margin-bottom: 0.75em; } +ul.toc li ul li ul { margin-bottom: 0.25em; } diff --git a/ServerSentEvents/user-agent-announce-connection.html b/ServerSentEvents/user-agent-announce-connection.html new file mode 100644 index 00000000000000..5b1d655a0e7232 --- /dev/null +++ b/ServerSentEvents/user-agent-announce-connection.html @@ -0,0 +1,32 @@ + + + + When a user agent is to announce the connection, the user agent must queue a task which, if the readyState attribute is set to a value other than CLOSED, sets the readyState attribute to OPEN and fires a simple event named open at the EventSource object: + + + + + + + + + + +

When a user agent is to announce the connection, the user agent must queue a task which, if the readyState attribute is set to a value other than CLOSED, sets the readyState attribute to OPEN and fires a simple event named open at the EventSource object:

+
+ + + + \ No newline at end of file