Skip to content
Myr

make `res.sendfile()` more like `res.download()`. Closes #774

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 5da28be · Browse files · 1 file+18 added−3 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+18 added−3 removed

  • other:+18 added−3 removed

1 file+18 added−3 removed

modified:lib/response.js+18 added-3 removed
145 unmodified lines
146 * Transfer the file at the given `path`.147 * 148 * Automatically sets the _Content-Type_ response header field.149 * The callback `fn(err)` is invoked when the transfer is complete150 * or when an error occurs. Be sure to check `res.headerSent`150 * or when an error occurs. Be sure to check `res.sentHeader`151 * if you wish to attempt responding, as the header and some data152 * may have already been transferred.153 *154 * Options:
20 unmodified lines
175176 // callback177 options.callback = function(err){178 // TODO: remove when node adds this179 self.headerSent = !! self._header;180 fn && fn(err);179 self.sentHeader = !! self._header;180181 // error182 if (err) {183 // ditch content-disposition to prevent funky responses184 if (!self.sentHeader) self.removeHeader('Content-Disposition');185186 // lost in limbo if there's no callback187 if (self.sentHeader) return fn && fn(err);188189 // callback available190 if (fn) return fn(err);191192 return self.req.next(err);193 }194195 fn && fn();196 };197198 // transfer199 options.path = encodeURIComponent(path);
264 unmodified lines