/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['middleware/timeout.js']) {
  _$jscoverage['middleware/timeout.js'] = [];
  _$jscoverage['middleware/timeout.js'][12] = 0;
  _$jscoverage['middleware/timeout.js'][30] = 0;
  _$jscoverage['middleware/timeout.js'][31] = 0;
  _$jscoverage['middleware/timeout.js'][33] = 0;
  _$jscoverage['middleware/timeout.js'][34] = 0;
  _$jscoverage['middleware/timeout.js'][35] = 0;
  _$jscoverage['middleware/timeout.js'][38] = 0;
  _$jscoverage['middleware/timeout.js'][39] = 0;
  _$jscoverage['middleware/timeout.js'][40] = 0;
  _$jscoverage['middleware/timeout.js'][41] = 0;
  _$jscoverage['middleware/timeout.js'][42] = 0;
  _$jscoverage['middleware/timeout.js'][43] = 0;
  _$jscoverage['middleware/timeout.js'][46] = 0;
  _$jscoverage['middleware/timeout.js'][47] = 0;
  _$jscoverage['middleware/timeout.js'][50] = 0;
  _$jscoverage['middleware/timeout.js'][51] = 0;
  _$jscoverage['middleware/timeout.js'][54] = 0;
}
_$jscoverage['middleware/timeout.js'][12]++;
var debug = require("debug")("connect:timeout");
_$jscoverage['middleware/timeout.js'][30]++;
module.exports = (function timeout(ms) {
  _$jscoverage['middleware/timeout.js'][31]++;
  ms = ms || 5000;
  _$jscoverage['middleware/timeout.js'][33]++;
  return (function (req, res, next) {
  _$jscoverage['middleware/timeout.js'][34]++;
  var id = setTimeout((function () {
  _$jscoverage['middleware/timeout.js'][35]++;
  req.emit("timeout", ms);
}), ms);
  _$jscoverage['middleware/timeout.js'][38]++;
  req.on("timeout", (function () {
  _$jscoverage['middleware/timeout.js'][39]++;
  if (req.headerSent) {
    _$jscoverage['middleware/timeout.js'][39]++;
    return debug("response started, cannot timeout");
  }
  _$jscoverage['middleware/timeout.js'][40]++;
  var err = new Error("Request timeout");
  _$jscoverage['middleware/timeout.js'][41]++;
  err.timeout = ms;
  _$jscoverage['middleware/timeout.js'][42]++;
  err.status = 408;
  _$jscoverage['middleware/timeout.js'][43]++;
  next(err);
}));
  _$jscoverage['middleware/timeout.js'][46]++;
  req.clearTimeout = (function () {
  _$jscoverage['middleware/timeout.js'][47]++;
  clearTimeout(id);
});
  _$jscoverage['middleware/timeout.js'][50]++;
  res.on("header", (function () {
  _$jscoverage['middleware/timeout.js'][51]++;
  clearTimeout(id);
}));
  _$jscoverage['middleware/timeout.js'][54]++;
  next();
});
});
_$jscoverage['middleware/timeout.js'].source = ["","/*!"," * Connect - timeout"," * Ported from https://github.com/LearnBoost/connect-timeout"," * MIT Licensed"," */","","/**"," * Module dependencies."," */","","var debug = require('debug')('connect:timeout');","","/**"," * Timeout:"," *"," * Times out the request in `ms`, defaulting to `5000`. The"," * method `req.clearTimeout()` is added to revert this behaviour"," * programmatically within your application's middleware, routes, etc."," *"," * The timeout error is passed to `next()` so that you may customize"," * the response behaviour. This error has the `.timeout` property as"," * well as `.status == 408`."," *"," * @param {Number} ms"," * @return {Function}"," * @api public"," */","","module.exports = function timeout(ms) {","  ms = ms || 5000;","","  return function(req, res, next) {","    var id = setTimeout(function(){","      req.emit('timeout', ms);","    }, ms);","","    req.on('timeout', function(){","      if (req.headerSent) return debug('response started, cannot timeout');","      var err = new Error('Request timeout');","      err.timeout = ms;","      err.status = 408;","      next(err);","    });","","    req.clearTimeout = function(){","      clearTimeout(id);","    };","","    res.on('header', function(){","      clearTimeout(id);","    });","","    next();","  };","};"];
