Skip to content
Myr

Persistant cookies

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent 9f4d2be · Browse files · 2 files+22 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+22 added−13 removed

  • tests:+4 added−6 removed
  • other:+18 added−7 removed

2 files+22 added−13 removed

modified:lib/express.core.js+18 added-7 removed
15 unmodified lines
16 // --- Defaults17 18 defaults : {19 cookie : {20 expires : 30020 maxAge : 360021 },22 route : {23 callback : function() {24 Express.status('Not Found')
10 unmodified lines
35 */36 37 start : function(port) {38 this.server.listen(port || 3000, function(request, response){39 // TODO: hooks / modules40 request.headers = Express.arrayToHash(request.headers)41 request.cookie = Express.parseCookie(request.headers['Cookie'])42 request.uri.params = Express.parseNestedParams(request.uri.params)43 request.uri.path = Express.normalizePath(request.uri.path)44 Express.request = request45 Express.response.cookie = request.cookie46 Express.response.body = Express.callRouteFor(request)45 response.sendHeader(Express.response.status, Express.hashToArray(Express.response.headers))47 response.sendHeader(Express.response.status, Express.prepareResponseHeaders(Express.hashToArray(Express.response.headers)))48 response.sendBody(Express.response.body || '')49 response.finish()50 })51 },
13 unmodified lines
65 puts('Express listening to http://localhost:' + port)66 }67 },68 69 prepareResponseHeaders : function(headers) {70 return headers71 },72 73 /**74 * Return an associative array generated75 * from the key / value pairs in _hash_.76 *
84 unmodified lines
161 * @api public162 */163164 cookie : function(key, value) {159 if (!value) return this.request.cookie[key]160 return this.response.cookie[key] = {161 key : key,162 value : value163 }165 return value ? this.response.cookie[key] = value :166 this.response.cookie[key]167 },168 169 /**170 * Parse _params_, splitting { user[info][name] : 'tj' } into
292 unmodified lines
463 p(request.cookie)464 param('operation') + 'ing ' + param('name')465})466467get('cookies', function(){468 cookie('foo', 'bar')469 p(request.headers)470 p(response.headers)471 p(response.cookie)472 'Wahoo!'473})474475get('articles', function(){476 display('spec/data/example.html.js')477 'list of articles'478})
13 unmodified lines
modified:spec/spec.core.js+4 added-6 removed