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 8ccceac · Browse files · 3 files+32 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

3 files+32 added−3 removed

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

3 files+32 added−3 removed

modified:lib/response.js+7 added-3 removed
254 unmodified lines
255 * Options:256 *257 * - `maxAge` defaulting to 0258 * - `root` root directory for relative filenames259 * - `hidden` serve hidden files, defaulting to false260 *261 * Other options are passed along to `send`.262 *263 * Examples:264 *265 * The following example illustrates how `res.sendfile()` may266 * be used as an alternative for the `static()` middleware for
66 unmodified lines
333 function cleanup() {334 req.socket.removeListener('error', error);335 }336337 // Back-compat338 options.maxage = options.maxage || options.maxAge || 0;339340 // transfer335 var file = send(req, path);336 if (options.root) file.root(options.root);337 file.maxage(options.maxAge || 0);341 var file = send(req, path, options);342 file.on('error', error);343 file.on('directory', next);344 file.on('stream', stream);345 file.pipe(this);
436 unmodified lines
added:test/fixtures/.name+1 added
1tobi
modified:test/res.sendfile.js+24 added
108 unmodified lines
109 })110 })111112 describe('.sendfile(path)', function(){113 it('should not serve hidden files', function(done){114 var app = express();115116 app.use(function(req, res){117 res.sendfile('test/fixtures/.name');118 });119120 request(app)121 .get('/')122 .expect(404, done);123 })124125 it('should accept hidden option', function(done){126 var app = express();127128 app.use(function(req, res){129 res.sendfile('test/fixtures/.name', { hidden: true });130 });131132 request(app)133 .get('/')134 .expect(200, 'tobi', done);135 })136137 describe('with an absolute path', function(){138 it('should transfer the file', function(done){139 var app = express();140
126 unmodified lines