Comparing version 2.2.1 to 2.2.2
2.2.2 / 2011-04-12 | ||
================== | ||
* Added second callback support for `res.download()` connection errors | ||
* Fixed `filename` option passing to template engine | ||
2.2.1 / 2011-04-04 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -30,3 +30,3 @@ | ||
exports.version = '2.2.1'; | ||
exports.version = '2.2.2'; | ||
@@ -33,0 +33,0 @@ /** |
@@ -133,2 +133,3 @@ | ||
res.sendfile = function(path, options, fn){ | ||
var next = this.req.next; | ||
options = options || {}; | ||
@@ -144,3 +145,3 @@ | ||
options.callback = fn; | ||
send(this.req, this, this.req.next, options); | ||
send(this.req, this, next, options); | ||
}; | ||
@@ -188,3 +189,5 @@ | ||
* Transfer the file at the given `path`, with optional | ||
* `filename` as an attachment and optional callback `fn(err)`. | ||
* `filename` as an attachment and optional callback `fn(err)`, | ||
* and optional `fn2(err)` which is invoked when an error has | ||
* occurred after headers have been sent. | ||
* | ||
@@ -194,7 +197,7 @@ * @param {String} path | ||
* @param {Function} fn | ||
* @return {Type} | ||
* @param {Function} fn2 | ||
* @api public | ||
*/ | ||
res.download = function(path, filename, fn){ | ||
res.download = function(path, filename, fn, fn2){ | ||
var self = this; | ||
@@ -204,2 +207,3 @@ | ||
if ('function' == typeof filename) { | ||
fn2 = fn; | ||
fn = filename; | ||
@@ -211,8 +215,14 @@ filename = null; | ||
this.attachment(filename || path).sendfile(path, function(err){ | ||
if (err) self.removeHeader('Content-Disposition'); | ||
if (fn) return fn(err); | ||
var sentHeader = self._header; | ||
if (err) { | ||
self.req.next('ENOENT' == err.code | ||
? null | ||
: err); | ||
if (!sentHeader) self.removeHeader('Content-Disposition'); | ||
if (sentHeader) { | ||
if (fn2) fn2(err); | ||
} else if (fn) { | ||
fn(err); | ||
} else { | ||
self.req.next(err); | ||
} | ||
} else if (fn) { | ||
fn(); | ||
} | ||
@@ -219,0 +229,0 @@ }); |
@@ -333,8 +333,6 @@ | ||
// Provide filename to engine | ||
options.filename = view.path; | ||
// cached view | ||
if (cache[view]) { | ||
view = cache[view]; | ||
options.filename = view.path; | ||
// resolve view | ||
@@ -368,2 +366,3 @@ } else { | ||
options.filename = view.path; | ||
var engine = view.templateEngine; | ||
@@ -370,0 +369,0 @@ view.fn = engine.compile(view.contents, options) |
{ | ||
"name": "express", | ||
"description": "Sinatra inspired web development framework", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -13,3 +13,3 @@ "contributors": [ | ||
"dependencies": { | ||
"connect": ">= 1.2.0 < 2.0.0", | ||
"connect": ">= 1.3.0 < 2.0.0", | ||
"mime": ">= 0.0.1", | ||
@@ -16,0 +16,0 @@ "qs": ">= 0.0.6" |
@@ -57,2 +57,3 @@ | ||
* [express-expose](http://github.com/visionmedia/express-expose) expose objects, functions, modules and more to client-side js with ease | ||
* [express-configure](http://github.com/visionmedia/express-configuration) async configuration support | ||
@@ -59,0 +60,0 @@ * [express-messages](http://github.com/visionmedia/express-messages) flash notification rendering helper |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87274
1839
99
Updatedconnect@>= 1.3.0 < 2.0.0