Sha256: 440a11df9efdd7637949c5ef692b57b94c46991cae44358244dedb338e28dd53

Contents?: true

Size: 871 Bytes

Versions: 28

Compression:

Stored size: 871 Bytes

Contents

/*!
 * Connect - cookieParser
 * Copyright(c) 2010 Sencha Inc.
 * Copyright(c) 2011 TJ Holowaychuk
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var utils = require('./../utils');

/**
 * Parse _Cookie_ header and populate `req.cookies`
 * with an object keyed by the cookie names.
 *
 * Examples:
 *
 *     connect.createServer(
 *         connect.cookieParser()
 *       , function(req, res, next){
 *         res.end(JSON.stringify(req.cookies));
 *       }
 *     );
 *
 * @return {Function}
 * @api public
 */

module.exports = function cookieParser(){
  return function cookieParser(req, res, next) {
    var cookie = req.headers.cookie;
    if (req.cookies) return next();
    req.cookies = {};
    if (cookie) {
      try {
        req.cookies = utils.parseCookie(cookie);
      } catch (err) {
        return next(err);
      }
    }
    next();
  };
};

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
blackboard-3.1.9 lib/site_template/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.8.2 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.8.1 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.8.0 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.7.2 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.7.1 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.7.0 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.6.1 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.6.0 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.5.0 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.4.0 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.3.0 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.2.5 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.2.4 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.2.3 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.2.2 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.2.1 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.2.0 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.1.6 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
vulcan-0.1.5 server/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js