Skip to content
Myr

Refactored res.sendfile()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent f6ba793 · Browse files · 1 file+13 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−11 removed

  • other:+13 added−11 removed

1 file+13 added−11 removed

modified:lib/express/response.js+13 added-11 removed
126 unmodified lines
127 */128129http.ServerResponse.prototype.sendfile = function(path, fn){130 var self = this;131 fs.readFile(path, function(err, buf){132 if (err) {133 delete self.headers['Content-Disposition'];134 if (fn) {135 fn(err, path);136 } else {137 self.req.next(err);138 }131132 function error(err) {133 delete self.headers['Content-Disposition'];134 if (fn) {135 fn(err, path);136 } else {140 self.contentType(path);141 self.send(buf);142 fn && fn(null, path);137 self.req.next(err);138 }139 }140141 fs.readFile(path, function(err, buf){142 if (err) return error(err);143 self.contentType(path);144 self.send(buf);145 fn && fn(null, path);146 });147};148149/**
172 unmodified lines