mirror of
https://github.com/seejohnrun/haste-server
synced 2025-07-14 09:03:45 -07:00
Added node modules
This commit is contained in:
parent
ca9d4c18f7
commit
d1e0644a4e
575 changed files with 77900 additions and 6 deletions
46
node_modules/connect/lib/middleware/cookieParser.js
generated
vendored
Normal file
46
node_modules/connect/lib/middleware/cookieParser.js
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
/*!
|
||||
* 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();
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue