cometd-nodejs-client
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -55,10 +55,12 @@ module.exports = { | ||
} | ||
var list = cookieStore[_config.hostname]; | ||
if (list) { | ||
var jar = cookieStore[_config.hostname]; | ||
if (jar) { | ||
var cookies = ''; | ||
for (var i = 0; i < list.length; ++i) { | ||
if (i > 0) { | ||
cookies += '; '; | ||
for (var name in jar) { | ||
if (jar.hasOwnProperty(name)) { | ||
if (cookies) { | ||
cookies += '; '; | ||
} | ||
cookies += jar[name]; | ||
} | ||
cookies += list[i]; | ||
} | ||
@@ -88,7 +90,11 @@ if (cookies) { | ||
var host = _config.hostname; | ||
var list = cookieStore[host]; | ||
if (list === undefined) { | ||
cookieStore[host] = list = []; | ||
var jar = cookieStore[host]; | ||
if (jar === undefined) { | ||
cookieStore[host] = jar = {}; | ||
} | ||
list.push(cookie); | ||
var equal = cookie.indexOf('='); | ||
if (equal > 0) { | ||
jar[cookie.substring(0, equal)] = cookie; | ||
} | ||
} | ||
@@ -95,0 +101,0 @@ } |
{ | ||
"name": "cometd-nodejs-client", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Adapter code to run the CometD JavaScript library in a NodeJS environment", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -147,2 +147,41 @@ var assert = require('assert'); | ||
}); | ||
it('handles cookie sent multiple times', function(done) { | ||
var cookieName = 'a'; | ||
var cookieValue = 'b'; | ||
var cookie = cookieName + '=' + cookieValue; | ||
_server = http.createServer(function(request, response) { | ||
if (/\/verify$/.test(request.url)) { | ||
assert.strictEqual(request.headers['cookie'], cookie); | ||
response.end(); | ||
} else { | ||
response.setHeader('Set-Cookie', cookie); | ||
response.end(); | ||
} | ||
}); | ||
_server.listen(0, 'localhost', function() { | ||
var port = _server.address().port; | ||
console.log('listening on localhost:' + port); | ||
var xhr1 = new window.XMLHttpRequest(); | ||
xhr1.open('GET', 'http://localhost:' + port + '/1'); | ||
xhr1.onload = function() { | ||
assert.strictEqual(xhr1.status, 200); | ||
var xhr2 = new window.XMLHttpRequest(); | ||
xhr2.open('GET', 'http://localhost:' + port + '/2'); | ||
xhr2.onload = function() { | ||
assert.strictEqual(xhr2.status, 200); | ||
var xhr3 = new window.XMLHttpRequest(); | ||
xhr3.open('GET', 'http://localhost:' + port + '/verify'); | ||
xhr3.onload = function() { | ||
assert.strictEqual(xhr1.status, 200); | ||
done(); | ||
}; | ||
xhr3.send(); | ||
}; | ||
xhr2.send(); | ||
}; | ||
xhr1.send(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80671
388