Skip to content
Myr

fixed `res.sendfile()` 404 support

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 d3ccdbc · Browse files · 2 files+7 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

2 files+7 added−3 removed

  • tests:+2 added−2 removed
  • other:+5 added−1 removed

2 files+7 added−3 removed

modified:lib/response.js+5 added-1 removed
162 unmodified lines
163 */164165res.sendfile = function(path, options, fn){166 var self = this167 , req = self.req168 , next = this.req.next169 , options = options || {};170171 // support function as second arg
11 unmodified lines
183 if (err) {184 // ditch content-disposition to prevent funky responses185 if (!self.sentHeader) self.removeHeader('Content-Disposition');186187 // not found188 if ('ENOENT' == err.code) return req.next();189190 // lost in limbo if there's no callback191 if (self.sentHeader) return fn && fn(err);192193 // callback available194 if (fn) return fn(err);195192 return self.req.next(err);196 return req.next(err);197 }198199 fn && fn();200 };
250 unmodified lines
modified:test/response.test.js+2 added-2 removed
499 unmodified lines
500 { body: 'got an error' });501 502 assert.response(app,503 { url: '/does-not-exist' },504 { body: 'got an error' });504 { body: 'Cannot GET /does-not-exist' });505 506 assert.response(app,507 { url: '/large.json' },508 { headers: { 'Accept-Ranges': 'bytes' }});
17 unmodified lines
526 });527 528 assert.response(app,529 { url: '/does-not-exist' },530 { body: 'got an error' });530 { body: 'Cannot GET /does-not-exist' });531 532 assert.response(app,533 { url: '/large.json' },534 { headers: {
239 unmodified lines