fixing cookies for connect 2.3.1
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 8930cd5 · Browse files · 4 files·+14 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+14 added−12 removed
- tests:+11 added−10 removed
- other:+3 added−2 removed
Provenance
- Commit
02d4384- Tree
a7dbc72- Author
TJ Holowaychuk <tj@vision-media.ca>- Committer
TJ Holowaychuk <tj@vision-media.ca>- Parent
8930cd5
4 files changed+14 added−12 removed
modified:lib/response.js+2 added-2 removed
10 unmodified lines11 , normalizeType = require('./utils').normalizeType12 , normalizeTypes = require('./utils').normalizeTypes13 , statusCodes = http.STATUS_CODES14 , send = connect.static.send15+ , cookie = require('cookie')16 , crc = require('crc')17 , mime = require('mime')18 , basename = path.basename19 , extname = path.extname461 unmodified lines481 if ('object' == typeof val) val = 'j:' + JSON.stringify(val);482 if (signed) val = utils.sign(val, secret);483 if ('maxAge' in options) options.expires = new Date(Date.now() + options.maxAge);484 if (null == options.path) options.path = '/';484- var cookie = utils.serializeCookie(name, val, options);485- this.set('Set-Cookie', cookie);485+ this.set('Set-Cookie', cookie.serialize(name, val, options));486 return this;487 };488 489 /**158 unmodified linesmodified:test/res.clearCookie.js+2 added-2 removed
12 unmodified lines131415161717181920219 unmodified lines313233343535363738392 unmodified lines12 unmodified lines
request(app) .get('/') .end(function(res){ var val = 'sid=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT'; var val = 'sid=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT'; res.headers['set-cookie'].should.eql([val]); done(); }) })9 unmodified lines
request(app) .get('/') .end(function(res){ var val = 'sid=; path=/admin; expires=Thu, 01 Jan 1970 00:00:00 GMT'; var val = 'sid=; Path=/admin; Expires=Thu, 01 Jan 1970 00:00:00 GMT'; res.headers['set-cookie'].should.eql([val]); done(); }) })2 unmodified linesmodified:test/res.cookie.js+9 added-8 removed
1233456785 unmodified lines141516171718192021229 unmodified lines323334353536373839409 unmodified lines5051525353545556575810 unmodified lines6970717272737475767729 unmodified lines10710810911011011111111211311411511610 unmodified lines1271281291301301311321331341353 unmodified lines
var express = require('../') , request = require('./support/http'); , request = require('./support/http') , cookie = require('cookie');
describe('res', function(){ describe('.cookie(name, object)', function(){ it('should generate a JSON cookie', function(done){5 unmodified lines
request(app) .get('/') .end(function(res){ var val = ['user=j%3A%7B%22name%22%3A%22tobi%22%7D; path=/']; var val = ['user=j:{%22name%22:%22tobi%22}; Path=/']; res.headers['set-cookie'].should.eql(val); done(); }) })9 unmodified lines
request(app) .get('/') .end(function(res){ var val = ['name=tobi; path=/']; var val = ['name=tobi; Path=/']; res.headers['set-cookie'].should.eql(val); done(); }) })9 unmodified lines
request(app) .get('/') .end(function(res){ var val = ['name=tobi; path=/', 'age=1; path=/']; var val = ['name=tobi; path=/', 'age=1; Path=/']; res.headers['set-cookie'].should.eql(val); done(); }) })10 unmodified lines
request(app) .get('/') .end(function(res){ var val = ['name=tobi; path=/; httpOnly; secure']; var val = ['name=tobi; Path=/; HttpOnly; Secure']; res.headers['set-cookie'].should.eql(val); done(); }) })29 unmodified lines request(app) .get('/') .end(function(res){ var val = res.headers['set-cookie'][0]; val = decodeURIComponent(val.split('.')[0]); val.should.equal('user=j:{"name":"tobi"}'); val = cookie.parse(val.split('.')[0]); val.user.should.equal('j:{"name":"tobi"}'); done(); }) }) })10 unmodified lines
request(app) .get('/') .end(function(res){ var val = ['name=tobi.xJjV2iZ6EI7C8E5kzwbfA9PVLl1ZR07UTnuTgQQ4EnQ; path=/']; var val = ['name=tobi.xJjV2iZ6EI7C8E5kzwbfA9PVLl1ZR07UTnuTgQQ4EnQ; Path=/']; res.headers['set-cookie'].should.eql(val); done(); }) })3 unmodified linesmodified:package.json+1 added
12 unmodified lines13 "connect": "2.3.1",14 "commander": "0.6.1",15 "mime": "1.2.5",16 "mkdirp": "0.3.2",17+ "cookie": "0.0.3",18 "crc": "0.2.0",19 "debug": "*"20 },21 "devDependencies": {20 unmodified lines