Skip to content

Commit

Permalink
Merge branch 'master' of github.com:visionmedia/express
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 24, 2012
2 parents d5e5647 + a861ea7 commit 3865168
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions bin/express
Expand Up @@ -195,7 +195,8 @@ var app = [
, ''
, 'var express = require(\'express\')'
, ' , routes = require(\'./routes\')'
, ' , http = require(\'http\');'
, ' , http = require(\'http\')'
, ' , path = require(\'path\');'
, ''
, 'var app = express();'
, ''
Expand All @@ -208,7 +209,7 @@ var app = [
, ' app.use(express.bodyParser());'
, ' app.use(express.methodOverride());{sess}'
, ' app.use(app.router);{css}'
, ' app.use(express.static(__dirname + \'/public\'));'
, ' app.use(express.static(path.join(__dirname, \'public\')));'
, '});'
, ''
, 'app.configure(\'development\', function(){'
Expand Down
10 changes: 8 additions & 2 deletions lib/response.js
Expand Up @@ -190,7 +190,7 @@ res.sendfile = function(path, options, fn){
done = true;

// clean up
req.socket.removeListener('error', error);
cleanup();
if (!self.headerSent) self.removeHeader('Content-Disposition');

// callback available
Expand All @@ -206,10 +206,15 @@ res.sendfile = function(path, options, fn){
// streaming
function stream() {
if (done) return;
req.socket.removeListener('error', error);
cleanup();
if (fn) self.on('finish', fn);
}

// cleanup
function cleanup() {
req.socket.removeListener('error', error);
}

// transfer
var file = send(req, path);
if (options.root) file.root(options.root);
Expand All @@ -218,6 +223,7 @@ res.sendfile = function(path, options, fn){
file.on('directory', next);
file.on('stream', stream);
file.pipe(this);
this.on('finish', cleanup);
};

/**
Expand Down

0 comments on commit 3865168

Please sign in to comment.