Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:remy/jsbin

  • Loading branch information...
commit 3b76eaa658d7f9ccab33d96287750689e2a3d7d2 2 parents e5e2a90 + 49ff16b
@remy remy authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/spike/index.js
View
10 lib/spike/index.js
@@ -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');
Please sign in to comment.
Something went wrong with that request. Please try again.