/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['middleware/cookieParser.js']) {
  _$jscoverage['middleware/cookieParser.js'] = [];
  _$jscoverage['middleware/cookieParser.js'][13] = 0;
  _$jscoverage['middleware/cookieParser.js'][38] = 0;
  _$jscoverage['middleware/cookieParser.js'][39] = 0;
  _$jscoverage['middleware/cookieParser.js'][40] = 0;
  _$jscoverage['middleware/cookieParser.js'][41] = 0;
  _$jscoverage['middleware/cookieParser.js'][43] = 0;
  _$jscoverage['middleware/cookieParser.js'][44] = 0;
  _$jscoverage['middleware/cookieParser.js'][45] = 0;
  _$jscoverage['middleware/cookieParser.js'][47] = 0;
  _$jscoverage['middleware/cookieParser.js'][48] = 0;
  _$jscoverage['middleware/cookieParser.js'][49] = 0;
  _$jscoverage['middleware/cookieParser.js'][50] = 0;
  _$jscoverage['middleware/cookieParser.js'][51] = 0;
  _$jscoverage['middleware/cookieParser.js'][52] = 0;
  _$jscoverage['middleware/cookieParser.js'][54] = 0;
  _$jscoverage['middleware/cookieParser.js'][56] = 0;
  _$jscoverage['middleware/cookieParser.js'][57] = 0;
  _$jscoverage['middleware/cookieParser.js'][60] = 0;
}
_$jscoverage['middleware/cookieParser.js'][13]++;
var utils = require("./../utils"), cookie = require("cookie");
_$jscoverage['middleware/cookieParser.js'][38]++;
module.exports = (function cookieParser(secret) {
  _$jscoverage['middleware/cookieParser.js'][39]++;
  return (function cookieParser(req, res, next) {
  _$jscoverage['middleware/cookieParser.js'][40]++;
  if (req.cookies) {
    _$jscoverage['middleware/cookieParser.js'][40]++;
    return next();
  }
  _$jscoverage['middleware/cookieParser.js'][41]++;
  var cookies = req.headers.cookie;
  _$jscoverage['middleware/cookieParser.js'][43]++;
  req.secret = secret;
  _$jscoverage['middleware/cookieParser.js'][44]++;
  req.cookies = {};
  _$jscoverage['middleware/cookieParser.js'][45]++;
  req.signedCookies = {};
  _$jscoverage['middleware/cookieParser.js'][47]++;
  if (cookies) {
    _$jscoverage['middleware/cookieParser.js'][48]++;
    try {
      _$jscoverage['middleware/cookieParser.js'][49]++;
      req.cookies = cookie.parse(cookies);
      _$jscoverage['middleware/cookieParser.js'][50]++;
      if (secret) {
        _$jscoverage['middleware/cookieParser.js'][51]++;
        req.signedCookies = utils.parseSignedCookies(req.cookies, secret);
        _$jscoverage['middleware/cookieParser.js'][52]++;
        req.signedCookies = utils.parseJSONCookies(req.signedCookies);
      }
      _$jscoverage['middleware/cookieParser.js'][54]++;
      req.cookies = utils.parseJSONCookies(req.cookies);
    }
    catch (err) {
      _$jscoverage['middleware/cookieParser.js'][56]++;
      err.status = 400;
      _$jscoverage['middleware/cookieParser.js'][57]++;
      return next(err);
    }
  }
  _$jscoverage['middleware/cookieParser.js'][60]++;
  next();
});
});
_$jscoverage['middleware/cookieParser.js'].source = ["","/*!"," * Connect - cookieParser"," * Copyright(c) 2010 Sencha Inc."," * Copyright(c) 2011 TJ Holowaychuk"," * MIT Licensed"," */","","/**"," * Module dependencies."," */","","var utils = require('./../utils')","  , cookie = require('cookie');","","/**"," * Cookie parser:"," *"," * Parse _Cookie_ header and populate `req.cookies`"," * with an object keyed by the cookie names. Optionally"," * you may enabled signed cookie support by passing"," * a `secret` string, which assigns `req.secret` so"," * it may be used by other middleware."," *"," * Examples:"," *"," *     connect()"," *       .use(connect.cookieParser('optional secret string'))"," *       .use(function(req, res, next){"," *         res.end(JSON.stringify(req.cookies));"," *       })"," *"," * @param {String} secret"," * @return {Function}"," * @api public"," */","","module.exports = function cookieParser(secret){","  return function cookieParser(req, res, next) {","    if (req.cookies) return next();","    var cookies = req.headers.cookie;","","    req.secret = secret;","    req.cookies = {};","    req.signedCookies = {};","","    if (cookies) {","      try {","        req.cookies = cookie.parse(cookies);","        if (secret) {","          req.signedCookies = utils.parseSignedCookies(req.cookies, secret);","          req.signedCookies = utils.parseJSONCookies(req.signedCookies);","        }","        req.cookies = utils.parseJSONCookies(req.cookies);","      } catch (err) {","        err.status = 400;","        return next(err);","      }","    }","    next();","  };","};"];
