mirror of
https://github.com/jsbin/jsbin.git
synced 2026-02-01 16:46:05 +00:00
Merge branch 'master' of github.com:remy/jsbin
This commit is contained in:
commit
3b76eaa658
@ -21,15 +21,15 @@ function keyForBin(bin) {
|
||||
return bin.url + '/' + bin.revision;
|
||||
}
|
||||
|
||||
function sessionForBin(bin) {
|
||||
function sessionForBin(bin, create) {
|
||||
var key = keyForBin(bin),
|
||||
session = sessions[key];
|
||||
|
||||
if (!session) {
|
||||
if (!session && create === true) {
|
||||
session = sessions[key] = { res: [], log: [] };
|
||||
}
|
||||
|
||||
return session;
|
||||
return session || null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
@ -42,7 +42,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
postLog: function (req, res, next) {
|
||||
var session = sessionForBin(req.bin);
|
||||
var session = sessionForBin(req.bin, true);
|
||||
|
||||
// passed over to Server Sent Events on jsconsole.com
|
||||
if (session) {
|
||||
@ -58,7 +58,7 @@ module.exports = {
|
||||
// Check request's accepts header for supported content types. If event
|
||||
// stream has precedence then return it otherwise pass on to next handler.
|
||||
if (req.headers.accept && req.headers.accept.indexOf('text/event-stream') !== -1) {
|
||||
var session = sessionForBin(req.bin);
|
||||
var session = sessionForBin(req.bin, true);
|
||||
|
||||
res.writeHead(200, {'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache'});
|
||||
res.write('id: 0\n\n');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user