/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['proto.js']) {
  _$jscoverage['proto.js'] = [];
  _$jscoverage['proto.js'][13] = 0;
  _$jscoverage['proto.js'][19] = 0;
  _$jscoverage['proto.js'][23] = 0;
  _$jscoverage['proto.js'][62] = 0;
  _$jscoverage['proto.js'][64] = 0;
  _$jscoverage['proto.js'][65] = 0;
  _$jscoverage['proto.js'][66] = 0;
  _$jscoverage['proto.js'][70] = 0;
  _$jscoverage['proto.js'][71] = 0;
  _$jscoverage['proto.js'][72] = 0;
  _$jscoverage['proto.js'][73] = 0;
  _$jscoverage['proto.js'][74] = 0;
  _$jscoverage['proto.js'][79] = 0;
  _$jscoverage['proto.js'][80] = 0;
  _$jscoverage['proto.js'][84] = 0;
  _$jscoverage['proto.js'][85] = 0;
  _$jscoverage['proto.js'][89] = 0;
  _$jscoverage['proto.js'][90] = 0;
  _$jscoverage['proto.js'][92] = 0;
  _$jscoverage['proto.js'][102] = 0;
  _$jscoverage['proto.js'][103] = 0;
  _$jscoverage['proto.js'][109] = 0;
  _$jscoverage['proto.js'][110] = 0;
  _$jscoverage['proto.js'][112] = 0;
  _$jscoverage['proto.js'][113] = 0;
  _$jscoverage['proto.js'][114] = 0;
  _$jscoverage['proto.js'][117] = 0;
  _$jscoverage['proto.js'][118] = 0;
  _$jscoverage['proto.js'][119] = 0;
  _$jscoverage['proto.js'][122] = 0;
  _$jscoverage['proto.js'][125] = 0;
  _$jscoverage['proto.js'][127] = 0;
  _$jscoverage['proto.js'][130] = 0;
  _$jscoverage['proto.js'][132] = 0;
  _$jscoverage['proto.js'][133] = 0;
  _$jscoverage['proto.js'][136] = 0;
  _$jscoverage['proto.js'][139] = 0;
  _$jscoverage['proto.js'][144] = 0;
  _$jscoverage['proto.js'][145] = 0;
  _$jscoverage['proto.js'][146] = 0;
  _$jscoverage['proto.js'][147] = 0;
  _$jscoverage['proto.js'][148] = 0;
  _$jscoverage['proto.js'][149] = 0;
  _$jscoverage['proto.js'][151] = 0;
  _$jscoverage['proto.js'][152] = 0;
  _$jscoverage['proto.js'][153] = 0;
  _$jscoverage['proto.js'][154] = 0;
  _$jscoverage['proto.js'][155] = 0;
  _$jscoverage['proto.js'][157] = 0;
  _$jscoverage['proto.js'][160] = 0;
  _$jscoverage['proto.js'][161] = 0;
  _$jscoverage['proto.js'][162] = 0;
  _$jscoverage['proto.js'][165] = 0;
  _$jscoverage['proto.js'][167] = 0;
  _$jscoverage['proto.js'][168] = 0;
  _$jscoverage['proto.js'][172] = 0;
  _$jscoverage['proto.js'][173] = 0;
  _$jscoverage['proto.js'][176] = 0;
  _$jscoverage['proto.js'][177] = 0;
  _$jscoverage['proto.js'][178] = 0;
  _$jscoverage['proto.js'][181] = 0;
  _$jscoverage['proto.js'][182] = 0;
  _$jscoverage['proto.js'][183] = 0;
  _$jscoverage['proto.js'][184] = 0;
  _$jscoverage['proto.js'][185] = 0;
  _$jscoverage['proto.js'][187] = 0;
  _$jscoverage['proto.js'][189] = 0;
  _$jscoverage['proto.js'][190] = 0;
  _$jscoverage['proto.js'][192] = 0;
  _$jscoverage['proto.js'][195] = 0;
  _$jscoverage['proto.js'][198] = 0;
  _$jscoverage['proto.js'][227] = 0;
  _$jscoverage['proto.js'][228] = 0;
  _$jscoverage['proto.js'][229] = 0;
}
_$jscoverage['proto.js'][13]++;
var http = require("http"), utils = require("./utils"), debug = require("debug")("connect:dispatcher");
_$jscoverage['proto.js'][19]++;
var app = module.exports = {};
_$jscoverage['proto.js'][23]++;
var env = process.env.NODE_ENV || "development";
_$jscoverage['proto.js'][62]++;
app.use = (function (route, fn) {
  _$jscoverage['proto.js'][64]++;
  if ("string" != typeof route) {
    _$jscoverage['proto.js'][65]++;
    fn = route;
    _$jscoverage['proto.js'][66]++;
    route = "/";
  }
  _$jscoverage['proto.js'][70]++;
  if ("function" == typeof fn.handle) {
    _$jscoverage['proto.js'][71]++;
    var server = fn;
    _$jscoverage['proto.js'][72]++;
    fn.route = route;
    _$jscoverage['proto.js'][73]++;
    fn = (function (req, res, next) {
  _$jscoverage['proto.js'][74]++;
  server.handle(req, res, next);
});
  }
  _$jscoverage['proto.js'][79]++;
  if (fn instanceof http.Server) {
    _$jscoverage['proto.js'][80]++;
    fn = fn.listeners("request")[0];
  }
  _$jscoverage['proto.js'][84]++;
  if ("/" == route[route.length - 1]) {
    _$jscoverage['proto.js'][85]++;
    route = route.slice(0, -1);
  }
  _$jscoverage['proto.js'][89]++;
  debug("use %s %s", route || "/", fn.name || "anonymous");
  _$jscoverage['proto.js'][90]++;
  this.stack.push({route: route, handle: fn});
  _$jscoverage['proto.js'][92]++;
  return this;
});
_$jscoverage['proto.js'][102]++;
app.handle = (function (req, res, out) {
  _$jscoverage['proto.js'][103]++;
  var stack = this.stack, fqdn = ~ req.url.indexOf("://"), removed = "", slashAdded = false, index = 0;
  _$jscoverage['proto.js'][109]++;
  function next(err) {
    _$jscoverage['proto.js'][110]++;
    var layer, path, status, c;
    _$jscoverage['proto.js'][112]++;
    if (slashAdded) {
      _$jscoverage['proto.js'][113]++;
      req.url = req.url.substr(1);
      _$jscoverage['proto.js'][114]++;
      slashAdded = false;
    }
    _$jscoverage['proto.js'][117]++;
    req.url = removed + req.url;
    _$jscoverage['proto.js'][118]++;
    req.originalUrl = req.originalUrl || req.url;
    _$jscoverage['proto.js'][119]++;
    removed = "";
    _$jscoverage['proto.js'][122]++;
    layer = stack[index++];
    _$jscoverage['proto.js'][125]++;
    if (! layer || res.headerSent) {
      _$jscoverage['proto.js'][127]++;
      if (out) {
        _$jscoverage['proto.js'][127]++;
        return out(err);
      }
      _$jscoverage['proto.js'][130]++;
      if (err) {
        _$jscoverage['proto.js'][132]++;
        if (res.statusCode < 400) {
          _$jscoverage['proto.js'][132]++;
          res.statusCode = 500;
        }
        _$jscoverage['proto.js'][133]++;
        debug("default %s", res.statusCode);
        _$jscoverage['proto.js'][136]++;
        if (err.status) {
          _$jscoverage['proto.js'][136]++;
          res.statusCode = err.status;
        }
        _$jscoverage['proto.js'][139]++;
        var msg = "production" == env? http.STATUS_CODES[res.statusCode]: err.stack || err.toString();
        _$jscoverage['proto.js'][144]++;
        if ("test" != env) {
          _$jscoverage['proto.js'][144]++;
          console.error(err.stack || err.toString());
        }
        _$jscoverage['proto.js'][145]++;
        if (res.headerSent) {
          _$jscoverage['proto.js'][145]++;
          return req.socket.destroy();
        }
        _$jscoverage['proto.js'][146]++;
        res.setHeader("Content-Type", "text/plain");
        _$jscoverage['proto.js'][147]++;
        res.setHeader("Content-Length", Buffer.byteLength(msg));
        _$jscoverage['proto.js'][148]++;
        if ("HEAD" == req.method) {
          _$jscoverage['proto.js'][148]++;
          return res.end();
        }
        _$jscoverage['proto.js'][149]++;
        res.end(msg);
      }
      else {
        _$jscoverage['proto.js'][151]++;
        debug("default 404");
        _$jscoverage['proto.js'][152]++;
        res.statusCode = 404;
        _$jscoverage['proto.js'][153]++;
        res.setHeader("Content-Type", "text/plain");
        _$jscoverage['proto.js'][154]++;
        if ("HEAD" == req.method) {
          _$jscoverage['proto.js'][154]++;
          return res.end();
        }
        _$jscoverage['proto.js'][155]++;
        res.end("Cannot " + req.method + " " + utils.escape(req.originalUrl));
      }
      _$jscoverage['proto.js'][157]++;
      return;
    }
    _$jscoverage['proto.js'][160]++;
    try {
      _$jscoverage['proto.js'][161]++;
      path = utils.parseUrl(req).pathname;
      _$jscoverage['proto.js'][162]++;
      if (undefined == path) {
        _$jscoverage['proto.js'][162]++;
        path = "/";
      }
      _$jscoverage['proto.js'][165]++;
      if (0 != path.toLowerCase().indexOf(layer.route.toLowerCase())) {
        _$jscoverage['proto.js'][165]++;
        return next(err);
      }
      _$jscoverage['proto.js'][167]++;
      c = path[layer.route.length];
      _$jscoverage['proto.js'][168]++;
      if (c && "/" != c && "." != c) {
        _$jscoverage['proto.js'][168]++;
        return next(err);
      }
      _$jscoverage['proto.js'][172]++;
      removed = layer.route;
      _$jscoverage['proto.js'][173]++;
      req.url = req.url.substr(removed.length);
      _$jscoverage['proto.js'][176]++;
      if (! fqdn && "/" != req.url[0]) {
        _$jscoverage['proto.js'][177]++;
        req.url = "/" + req.url;
        _$jscoverage['proto.js'][178]++;
        slashAdded = true;
      }
      _$jscoverage['proto.js'][181]++;
      debug("%s", layer.handle.name || "anonymous");
      _$jscoverage['proto.js'][182]++;
      var arity = layer.handle.length;
      _$jscoverage['proto.js'][183]++;
      if (err) {
        _$jscoverage['proto.js'][184]++;
        if (arity === 4) {
          _$jscoverage['proto.js'][185]++;
          layer.handle(err, req, res, next);
        }
        else {
          _$jscoverage['proto.js'][187]++;
          next(err);
        }
      }
      else {
        _$jscoverage['proto.js'][189]++;
        if (arity < 4) {
          _$jscoverage['proto.js'][190]++;
          layer.handle(req, res, next);
        }
        else {
          _$jscoverage['proto.js'][192]++;
          next();
        }
      }
    }
    catch (e) {
      _$jscoverage['proto.js'][195]++;
      next(e);
    }
}
  _$jscoverage['proto.js'][198]++;
  next();
});
_$jscoverage['proto.js'][227]++;
app.listen = (function () {
  _$jscoverage['proto.js'][228]++;
  var server = http.createServer(this);
  _$jscoverage['proto.js'][229]++;
  return server.listen.apply(server, arguments);
});
_$jscoverage['proto.js'].source = ["","/*!"," * Connect - HTTPServer"," * Copyright(c) 2010 Sencha Inc."," * Copyright(c) 2011 TJ Holowaychuk"," * MIT Licensed"," */","","/**"," * Module dependencies."," */","","var http = require('http')","  , utils = require('./utils')","  , debug = require('debug')('connect:dispatcher');","","// prototype","","var app = module.exports = {};","","// environment","","var env = process.env.NODE_ENV || 'development';","","/**"," * Utilize the given middleware `handle` to the given `route`,"," * defaulting to _/_. This \"route\" is the mount-point for the"," * middleware, when given a value other than _/_ the middleware"," * is only effective when that segment is present in the request's"," * pathname."," *"," * For example if we were to mount a function at _/admin_, it would"," * be invoked on _/admin_, and _/admin/settings_, however it would"," * not be invoked for _/_, or _/posts_."," *"," * Examples:"," *"," *      var app = connect();"," *      app.use(connect.favicon());"," *      app.use(connect.logger());"," *      app.use(connect.static(__dirname + '/public'));"," *"," * If we wanted to prefix static files with _/public_, we could"," * \"mount\" the `static()` middleware:"," *"," *      app.use('/public', connect.static(__dirname + '/public'));"," *"," * This api is chainable, so the following is valid:"," *"," *      connect()"," *        .use(connect.favicon())"," *        .use(connect.logger())"," *        .use(connect.static(__dirname + '/public'))"," *        .listen(3000);"," *"," * @param {String|Function|Server} route, callback or server"," * @param {Function|Server} callback or server"," * @return {Server} for chaining"," * @api public"," */","","app.use = function(route, fn){","  // default route to '/'","  if ('string' != typeof route) {","    fn = route;","    route = '/';","  }","","  // wrap sub-apps","  if ('function' == typeof fn.handle) {","    var server = fn;","    fn.route = route;","    fn = function(req, res, next){","      server.handle(req, res, next);","    };","  }","","  // wrap vanilla http.Servers","  if (fn instanceof http.Server) {","    fn = fn.listeners('request')[0];","  }","","  // strip trailing slash","  if ('/' == route[route.length - 1]) {","    route = route.slice(0, -1);","  }","","  // add the middleware","  debug('use %s %s', route || '/', fn.name || 'anonymous');","  this.stack.push({ route: route, handle: fn });","","  return this;","};","","/**"," * Handle server requests, punting them down"," * the middleware stack."," *"," * @api private"," */","","app.handle = function(req, res, out) {","  var stack = this.stack","    , fqdn = ~req.url.indexOf('://')","    , removed = ''","    , slashAdded = false","    , index = 0;","","  function next(err) {","    var layer, path, status, c;","","    if (slashAdded) {","      req.url = req.url.substr(1);","      slashAdded = false;","    }","","    req.url = removed + req.url;","    req.originalUrl = req.originalUrl || req.url;","    removed = '';","","    // next callback","    layer = stack[index++];","","    // all done","    if (!layer || res.headerSent) {","      // delegate to parent","      if (out) return out(err);","","      // unhandled error","      if (err) {","        // default to 500","        if (res.statusCode &lt; 400) res.statusCode = 500;","        debug('default %s', res.statusCode);","","        // respect err.status","        if (err.status) res.statusCode = err.status;","","        // production gets a basic error message","        var msg = 'production' == env","          ? http.STATUS_CODES[res.statusCode]","          : err.stack || err.toString();","","        // log to stderr in a non-test env","        if ('test' != env) console.error(err.stack || err.toString());","        if (res.headerSent) return req.socket.destroy();","        res.setHeader('Content-Type', 'text/plain');","        res.setHeader('Content-Length', Buffer.byteLength(msg));","        if ('HEAD' == req.method) return res.end();","        res.end(msg);","      } else {","        debug('default 404');","        res.statusCode = 404;","        res.setHeader('Content-Type', 'text/plain');","        if ('HEAD' == req.method) return res.end();","        res.end('Cannot ' + req.method + ' ' + utils.escape(req.originalUrl));","      }","      return;","    }","","    try {","      path = utils.parseUrl(req).pathname;","      if (undefined == path) path = '/';","","      // skip this layer if the route doesn't match.","      if (0 != path.toLowerCase().indexOf(layer.route.toLowerCase())) return next(err);","","      c = path[layer.route.length];","      if (c &amp;&amp; '/' != c &amp;&amp; '.' != c) return next(err);","","      // Call the layer handler","      // Trim off the part of the url that matches the route","      removed = layer.route;","      req.url = req.url.substr(removed.length);","","      // Ensure leading slash","      if (!fqdn &amp;&amp; '/' != req.url[0]) {","        req.url = '/' + req.url;","        slashAdded = true;","      }","","      debug('%s', layer.handle.name || 'anonymous');","      var arity = layer.handle.length;","      if (err) {","        if (arity === 4) {","          layer.handle(err, req, res, next);","        } else {","          next(err);","        }","      } else if (arity &lt; 4) {","        layer.handle(req, res, next);","      } else {","        next();","      }","    } catch (e) {","      next(e);","    }","  }","  next();","};","","/**"," * Listen for connections."," *"," * This method takes the same arguments"," * as node's `http.Server#listen()`.  "," *"," * HTTP and HTTPS:"," *"," * If you run your application both as HTTP"," * and HTTPS you may wrap them individually,"," * since your Connect \"server\" is really just"," * a JavaScript `Function`."," *"," *      var connect = require('connect')"," *        , http = require('http')"," *        , https = require('https');"," *      "," *      var app = connect();"," *      "," *      http.createServer(app).listen(80);"," *      https.createServer(options, app).listen(443);"," *"," * @return {http.Server}"," * @api public"," */","","app.listen = function(){","  var server = http.createServer(this);","  return server.listen.apply(server, arguments);","};"];
