Skip to content
Myr

Pass options from res.sendfile to send

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

fixes #2017

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 323c185 · Browse files · 4 files+32 added−6 removed
This commit

State

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

Diff stats

4 files+32 added−6 removed

  • tests:+25 added−0 removed
  • other:+7 added−6 removed

4 files+32 added−6 removed

modified:lib/response.js+6 added-6 removed
306 unmodified lines
307 * may have already been transferred.308 *309 * Options:310 *311 * - `maxAge` defaulting to 0312 * - `root` root directory for relative filenames311 * - `maxAge` defaulting to 0312 * - `root` root directory for relative filenames313 * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them314 *315 * Other options are passed along to `send`.316 *317 * Examples:318 *319 * The following example illustrates how `res.sendfile()` may320 * be used as an alternative for the `static()` middleware for
66 unmodified lines
387 req.socket.removeListener('error', error);388 }389390 // transfer388 var file = send(req, path, {389 maxAge: options.maxAge || 0,390 root: options.root391 });391 var file = send(req, path, options);392 file.on('error', error);393 file.on('directory', next);394 file.on('stream', stream);395 file.pipe(this);
433 unmodified lines
added:test/fixtures/.name+1 added
1tobi
modified:test/res.sendfile.js+24 added
104 unmodified lines
105 })106 })107108 describe('.sendfile(path)', function(){109 it('should not serve dotfiles', function(done){110 var app = express();111112 app.use(function(req, res){113 res.sendfile('test/fixtures/.name');114 });115116 request(app)117 .get('/')118 .expect(404, done);119 })120121 it('should accept dotfiles option', function(done){122 var app = express();123124 app.use(function(req, res){125 res.sendfile('test/fixtures/.name', { dotfiles: 'allow' });126 });127128 request(app)129 .get('/')130 .expect(200, 'tobi', done);131 })132133 describe('with an absolute path', function(){134 it('should transfer the file', function(done){135 var app = express();136
126 unmodified lines
modified:History.md+1 added
13.x2===34 * Pass options from `res.sendfile` to `send`5 * deps: connect@2.24.06 - deps: body-parser@~1.5.07 - deps: compression@~1.0.98 - deps: connect-timeout@~1.2.1
1557 unmodified lines