Permalink
Browse files

Added throwError option

  • Loading branch information...
1 parent 8f78761 commit 02dd27f03ef152bd0688a5e7b2d96d701a8c3c18 @rauchg rauchg committed Aug 5, 2010
Showing with 7 additions and 2 deletions.
  1. +7 −2 index.js
View
@@ -2,12 +2,17 @@ module.exports = function responseTimeout(options){
options = options || {};
options.time = options.time || 8000;
options.code = options.code || 500;
+ options.throwError = options.throwError || options.throwError === undefined;
return function responseTimeout(req, res, next){
var writeHead = res.writeHead,
timer = setTimeout(function(){
- res.writeHead(options.code);
- res.end();
+ if (options.throwError){
+ next(new Error('Timeout'));
+ } else {
+ res.writeHead(options.code);
+ res.end();
+ }
}, options.time);
req.clearTimeout = function(){

0 comments on commit 02dd27f

Please sign in to comment.