blob: 6627fefa9fca5efe2b50e4e925d79538225f755f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
function handleRequest(request, response) {
var name = "eventsource_reconnecting_" + request.queryString;
var reconnecting = getState(name);
var body = "";
if (!reconnecting) {
body = "retry: 2\n";
setState(name, "0");
} else if (reconnecting === "0") {
setState(name, "");
response.setStatusLine(request.httpVersion, 204, "No Content");
}
response.setHeader("Content-Type", "text/event-stream");
response.setHeader("Cache-Control", "no-cache");
body += "data: 1\n\n";
response.write(body);
}
|