Skip to content
Myr

Added HEAD support to 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 fb33671 · Browse files · 1 file+4 added−1 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+4 added−1 removed

  • other:+4 added−1 removed

1 file+4 added−1 removed

modified:lib/express/response.js+4 added-1 removed
135 unmodified lines
136137http.ServerResponse.prototype.sendfile = function(path, fn){138 var self = this139 , streamThreshold = this.app.set('stream threshold') || 32 * 1024140 , ranges = self.req.headers.range;140 , ranges = self.req.headers.range141 , head = 'HEAD' == self.req.method;142143 if (~path.indexOf('..')) this.send(403);144145 function error(err) {
26 unmodified lines
172 }173 self.contentType(path);174 self.header('Accept-Ranges', 'bytes');175 self.writeHead(status, self.headers);176 if (head) return self.end();177 pump(stream, self, function(err){178 fn && fn(err, path, true);179 });180 } else {181 fs.readFile(path, function(err, buf){182 if (err) return error(err);183 self.contentType(path);184 if (head) return self.end();185 self.send(buf);186 fn && fn(null, path);187 });188 }
208 unmodified lines