Skip to content
Myr

res.sendFile.js

This file

Path

test/res.sendFile.js

803 lines · 20.2 KiB · JavaScript

Last changed by

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

History of this file

Take it

The walk stopped after 200 commits: lines older than dc48f27 point at it.

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 1–99why, one step back
1
2var after = require('after');3var express = require('../')4 , request = require('supertest')5 , assert = require('assert');6var onFinished = require('on-finished');7var path = require('path');8var should = require('should');9var fixtures = path.join(__dirname, 'fixtures');10var utils = require('./support/utils');1112describe('res', function(){13 describe('.sendFile(path)', function () {14 it('should error missing path', function (done) {15 var app = createApp();1617 request(app)18 .get('/')19 .expect(500, /path.*required/, done);20 });2122 it('should transfer a file', function (done) {23 var app = createApp(path.resolve(fixtures, 'name.txt'));2425 request(app)26 .get('/')27 .expect(200, 'tobi', done);28 });2930 it('should transfer a file with special characters in string', function (done) {31 var app = createApp(path.resolve(fixtures, '% of dogs.txt'));3233 request(app)34 .get('/')35 .expect(200, '20%', done);36 });3738 it('should include ETag', function (done) {39 var app = createApp(path.resolve(fixtures, 'name.txt'));4041 request(app)42 .get('/')43 .expect('ETag', /^(?:W\/)?"[^"]+"$/)44 .expect(200, 'tobi', done);45 });4647 it('should 304 when ETag matches', function (done) {48 var app = createApp(path.resolve(fixtures, 'name.txt'));4950 request(app)51 .get('/')52 .expect('ETag', /^(?:W\/)?"[^"]+"$/)53 .expect(200, 'tobi', function (err, res) {54 if (err) return done(err);55 var etag = res.headers.etag;56 request(app)57 .get('/')58 .set('If-None-Match', etag)59 .expect(304, done);60 });61 });6263 it('should 404 for directory', function (done) {64 var app = createApp(path.resolve(fixtures, 'blog'));6566 request(app)67 .get('/')68 .expect(404, done);69 });7071 it('should 404 when not found', function (done) {72 var app = createApp(path.resolve(fixtures, 'does-no-exist'));7374 app.use(function (req, res) {75 res.statusCode = 200;76 res.send('no!');77 });7879 request(app)80 .get('/')81 .expect(404, done);82 });8384 it('should not override manual content-types', function (done) {85 var app = express();8687 app.use(function (req, res) {88 res.contentType('application/x-bogus');89 res.sendFile(path.resolve(fixtures, 'name.txt'));90 });9192 request(app)93 .get('/')94 .expect('Content-Type', 'application/x-bogus')95 .end(done);96 })9798 it('should not error if the client aborts', function (done) {99 var app = express();

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

lines 100–101why, one step back
100 var cb = after(2, done)
101 var error = null

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 102–105why, one step back
102
103 app.use(function (req, res) {104 setImmediate(function () {105 res.sendFile(path.resolve(fixtures, 'name.txt'));

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

line 106why, one step back
106 server.close(cb)

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

lines 107–110why, one step back
107 setTimeout(function () {
108 cb(error)109 }, 10)110 })

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 111–114why, one step back
111 test.abort();
112 });113114 app.use(function (err, req, res, next) {

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

lines 115–116why, one step back
115 error = err
116 next(err)

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 117–118why, one step back
117 });
118

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

lines 119–120why, one step back
119 var server = app.listen()
120 var test = request(server).get('/')

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

line 121why, one step back
121 test.end()

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 122–164why, one step back
122 })
123124 describe('with "cacheControl" option', function () {125 it('should enable cacheControl by default', function (done) {126 var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'))127128 request(app)129 .get('/')130 .expect('Cache-Control', 'public, max-age=0')131 .expect(200, done)132 })133134 it('should accept cacheControl option', function (done) {135 var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'), { cacheControl: false })136137 request(app)138 .get('/')139 .expect(utils.shouldNotHaveHeader('Cache-Control'))140 .expect(200, done)141 })142 })143144 describe('with "dotfiles" option', function () {145 it('should not serve dotfiles by default', function (done) {146 var app = createApp(path.resolve(__dirname, 'fixtures/.name'));147148 request(app)149 .get('/')150 .expect(404, done);151 });152153 it('should accept dotfiles option', function(done){154 var app = createApp(path.resolve(__dirname, 'fixtures/.name'), { dotfiles: 'allow' });155156 request(app)157 .get('/')158 .expect(200, 'tobi', done);159 });160 });161162 describe('with "headers" option', function () {163 it('should accept headers option', function (done) {164 var headers = {

lint: fix broken indentation in testsDouglas Christopher Wilsonbefore adoptionfb3946f

lines 165–166why, one step back
165 'x-success': 'sent',
166 'x-other': 'done'

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 167–187why, one step back
167 };
168 var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'), { headers: headers });169170 request(app)171 .get('/')172 .expect('x-success', 'sent')173 .expect('x-other', 'done')174 .expect(200, done);175 });176177 it('should ignore headers option on 404', function (done) {178 var headers = { 'x-success': 'sent' };179 var app = createApp(path.resolve(__dirname, 'fixtures/does-not-exist'), { headers: headers });180181 request(app)182 .get('/')183 .expect(utils.shouldNotHaveHeader('X-Success'))184 .expect(404, done);185 });186 });187

deps: send@0.16.0Daniel Tschinderbefore adoption4196458

lines 188–201why, one step back
188 describe('with "immutable" option', function () {
189 it('should add immutable cache-control directive', function (done) {190 var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'), {191 immutable: true,192 maxAge: '4h'193 })194195 request(app)196 .get('/')197 .expect('Cache-Control', 'public, max-age=14400, immutable')198 .expect(200, done)199 })200 })201

tests: add maxAge option tests for res.sendFileDouglas Christopher Wilsonbefore adoptionddeb713

lines 202–225why, one step back
202 describe('with "maxAge" option', function () {
203 it('should set cache-control max-age from number', function (done) {204 var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'), {205 maxAge: 14400000206 })207208 request(app)209 .get('/')210 .expect('Cache-Control', 'public, max-age=14400')211 .expect(200, done)212 })213214 it('should set cache-control max-age from string', function (done) {215 var app = createApp(path.resolve(__dirname, 'fixtures/name.txt'), {216 maxAge: '4h'217 })218219 request(app)220 .get('/')221 .expect('Cache-Control', 'public, max-age=14400')222 .expect(200, done)223 })224 })225

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 226–269why, one step back
226 describe('with "root" option', function () {
227 it('should not transfer relative with without', function (done) {228 var app = createApp('test/fixtures/name.txt');229230 request(app)231 .get('/')232 .expect(500, /must be absolute/, done);233 })234235 it('should serve relative to "root"', function (done) {236 var app = createApp('name.txt', {root: fixtures});237238 request(app)239 .get('/')240 .expect(200, 'tobi', done);241 })242243 it('should disallow requesting out of "root"', function (done) {244 var app = createApp('foo/../../user.html', {root: fixtures});245246 request(app)247 .get('/')248 .expect(403, done);249 })250 })251 })252253 describe('.sendFile(path, fn)', function () {254 it('should invoke the callback when complete', function (done) {255 var cb = after(2, done);256 var app = createApp(path.resolve(fixtures, 'name.txt'), cb);257258 request(app)259 .get('/')260 .expect(200, cb);261 })262263 it('should invoke the callback when client aborts', function (done) {264 var cb = after(1, done);265 var app = express();266267 app.use(function (req, res) {268 setImmediate(function () {269 res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {

tests: fix incorrect should usageDaniel Walasekbefore adoption713d2ae

line 270why, one step back
270 should(err).be.ok()

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

line 271why, one step back
271 err.code.should.equal('ECONNABORTED');

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

line 272why, one step back
272 server.close(cb)

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 273–277why, one step back
273 });
274 });275 test.abort();276 });277

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

lines 278–279why, one step back
278 var server = app.listen()
279 var test = request(server).get('/')

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 280–289why, one step back
280 test.expect(200, cb);
281 })282283 it('should invoke the callback when client already aborted', function (done) {284 var cb = after(1, done);285 var app = express();286287 app.use(function (req, res) {288 onFinished(res, function () {289 res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {

tests: fix incorrect should usageDaniel Walasekbefore adoption713d2ae

line 290why, one step back
290 should(err).be.ok()

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

line 291why, one step back
291 err.code.should.equal('ECONNABORTED');

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

line 292why, one step back
292 server.close(cb)

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 293–297why, one step back
293 });
294 });295 test.abort();296 });297

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

lines 298–299why, one step back
298 var server = app.listen()
299 var test = request(server).get('/')

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 300–341why, one step back
300 test.expect(200, cb);
301 })302303 it('should invoke the callback without error when HEAD', function (done) {304 var app = express();305 var cb = after(2, done);306307 app.use(function (req, res) {308 res.sendFile(path.resolve(fixtures, 'name.txt'), cb);309 });310311 request(app)312 .head('/')313 .expect(200, cb);314 });315316 it('should invoke the callback without error when 304', function (done) {317 var app = express();318 var cb = after(3, done);319320 app.use(function (req, res) {321 res.sendFile(path.resolve(fixtures, 'name.txt'), cb);322 });323324 request(app)325 .get('/')326 .expect('ETag', /^(?:W\/)?"[^"]+"$/)327 .expect(200, 'tobi', function (err, res) {328 if (err) return cb(err);329 var etag = res.headers.etag;330 request(app)331 .get('/')332 .set('If-None-Match', etag)333 .expect(304, cb);334 });335 });336337 it('should invoke the callback on 404', function(done){338 var app = express();339340 app.use(function (req, res) {341 res.sendFile(path.resolve(fixtures, 'does-not-exist'), function (err) {

tests: fix incorrect should usageDaniel Walasekbefore adoption713d2ae

line 342why, one step back
342 should(err).be.ok()

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 343–395why, one step back
343 err.status.should.equal(404);
344 res.send('got it');345 });346 });347348 request(app)349 .get('/')350 .expect(200, 'got it', done);351 })352 })353354 describe('.sendFile(path, options)', function () {355 it('should pass options to send module', function (done) {356 request(createApp(path.resolve(fixtures, 'name.txt'), { start: 0, end: 1 }))357 .get('/')358 .expect(200, 'to', done)359 })360 })361362 describe('.sendfile(path, fn)', function(){363 it('should invoke the callback when complete', function(done){364 var app = express();365 var cb = after(2, done);366367 app.use(function(req, res){368 res.sendfile('test/fixtures/user.html', cb)369 });370371 request(app)372 .get('/')373 .expect(200, cb);374 })375376 it('should utilize the same options as express.static()', function(done){377 var app = express();378379 app.use(function(req, res){380 res.sendfile('test/fixtures/user.html', { maxAge: 60000 });381 });382383 request(app)384 .get('/')385 .expect('Cache-Control', 'public, max-age=60')386 .end(done);387 })388389 it('should invoke the callback when client aborts', function (done) {390 var cb = after(1, done);391 var app = express();392393 app.use(function (req, res) {394 setImmediate(function () {395 res.sendfile('test/fixtures/name.txt', function (err) {

tests: fix incorrect should usageDaniel Walasekbefore adoption713d2ae

line 396why, one step back
396 should(err).be.ok()

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

line 397why, one step back
397 err.code.should.equal('ECONNABORTED');

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

line 398why, one step back
398 server.close(cb)

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 399–403why, one step back
399 });
400 });401 test.abort();402 });403

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

lines 404–405why, one step back
404 var server = app.listen()
405 var test = request(server).get('/')

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 406–415why, one step back
406 test.expect(200, cb);
407 })408409 it('should invoke the callback when client already aborted', function (done) {410 var cb = after(1, done);411 var app = express();412413 app.use(function (req, res) {414 onFinished(res, function () {415 res.sendfile('test/fixtures/name.txt', function (err) {

tests: fix incorrect should usageDaniel Walasekbefore adoption713d2ae

line 416why, one step back
416 should(err).be.ok()

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

line 417why, one step back
417 err.code.should.equal('ECONNABORTED');

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

line 418why, one step back
418 server.close(cb)

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 419–423why, one step back
419 });
420 });421 test.abort();422 });423

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

lines 424–425why, one step back
424 var server = app.listen()
425 var test = request(server).get('/')

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 426–556why, one step back
426 test.expect(200, cb);
427 })428429 it('should invoke the callback without error when HEAD', function (done) {430 var app = express();431 var cb = after(2, done);432433 app.use(function (req, res) {434 res.sendfile('test/fixtures/name.txt', cb);435 });436437 request(app)438 .head('/')439 .expect(200, cb);440 });441442 it('should invoke the callback without error when 304', function (done) {443 var app = express();444 var cb = after(3, done);445446 app.use(function (req, res) {447 res.sendfile('test/fixtures/name.txt', cb);448 });449450 request(app)451 .get('/')452 .expect('ETag', /^(?:W\/)?"[^"]+"$/)453 .expect(200, 'tobi', function (err, res) {454 if (err) return cb(err);455 var etag = res.headers.etag;456 request(app)457 .get('/')458 .set('If-None-Match', etag)459 .expect(304, cb);460 });461 });462463 it('should invoke the callback on 404', function(done){464 var app = express();465 var calls = 0;466467 app.use(function(req, res){468 res.sendfile('test/fixtures/nope.html', function(err){469 assert.equal(calls++, 0);470 assert(!res.headersSent);471 res.send(err.message);472 });473 });474475 request(app)476 .get('/')477 .expect(200, /^ENOENT.*?, stat/, done);478 })479480 it('should not override manual content-types', function(done){481 var app = express();482483 app.use(function(req, res){484 res.contentType('txt');485 res.sendfile('test/fixtures/user.html');486 });487488 request(app)489 .get('/')490 .expect('Content-Type', 'text/plain; charset=utf-8')491 .end(done);492 })493494 it('should invoke the callback on 403', function(done){495 var app = express()496497 app.use(function(req, res){498 res.sendfile('test/fixtures/foo/../user.html', function(err){499 assert(!res.headersSent);500 res.send(err.message);501 });502 });503504 request(app)505 .get('/')506 .expect('Forbidden')507 .expect(200, done);508 })509510 it('should invoke the callback on socket error', function(done){511 var app = express()512513 app.use(function(req, res){514 res.sendfile('test/fixtures/user.html', function(err){515 assert(!res.headersSent);516 req.socket.listeners('error').should.have.length(1); // node's original handler517 done();518 });519520 req.socket.emit('error', new Error('broken!'));521 });522523 request(app)524 .get('/')525 .end(function(){});526 })527 })528529 describe('.sendfile(path)', function(){530 it('should not serve dotfiles', function(done){531 var app = express();532533 app.use(function(req, res){534 res.sendfile('test/fixtures/.name');535 });536537 request(app)538 .get('/')539 .expect(404, done);540 })541542 it('should accept dotfiles option', function(done){543 var app = express();544545 app.use(function(req, res){546 res.sendfile('test/fixtures/.name', { dotfiles: 'allow' });547 });548549 request(app)550 .get('/')551 .expect(200, 'tobi', done);552 })553554 it('should accept headers option', function(done){555 var app = express();556 var headers = {

lint: fix broken indentation in testsDouglas Christopher Wilsonbefore adoptionfb3946f

lines 557–558why, one step back
557 'x-success': 'sent',
558 'x-other': 'done'

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 559–635why, one step back
559 };
560561 app.use(function(req, res){562 res.sendfile('test/fixtures/user.html', { headers: headers });563 });564565 request(app)566 .get('/')567 .expect('x-success', 'sent')568 .expect('x-other', 'done')569 .expect(200, done);570 })571572 it('should ignore headers option on 404', function(done){573 var app = express();574 var headers = { 'x-success': 'sent' };575576 app.use(function(req, res){577 res.sendfile('test/fixtures/user.nothing', { headers: headers });578 });579580 request(app)581 .get('/')582 .expect(utils.shouldNotHaveHeader('X-Success'))583 .expect(404, done);584 })585586 it('should transfer a file', function (done) {587 var app = express();588589 app.use(function (req, res) {590 res.sendfile('test/fixtures/name.txt');591 });592593 request(app)594 .get('/')595 .expect(200, 'tobi', done);596 });597598 it('should transfer a directory index file', function (done) {599 var app = express();600601 app.use(function (req, res) {602 res.sendfile('test/fixtures/blog/');603 });604605 request(app)606 .get('/')607 .expect(200, '<b>index</b>', done);608 });609610 it('should 404 for directory without trailing slash', function (done) {611 var app = express();612613 app.use(function (req, res) {614 res.sendfile('test/fixtures/blog');615 });616617 request(app)618 .get('/')619 .expect(404, done);620 });621622 it('should transfer a file with urlencoded name', function (done) {623 var app = express();624625 app.use(function (req, res) {626 res.sendfile('test/fixtures/%25%20of%20dogs.txt');627 });628629 request(app)630 .get('/')631 .expect(200, '20%', done);632 });633634 it('should not error if the client aborts', function (done) {635 var app = express();

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

lines 636–637why, one step back
636 var cb = after(2, done)
637 var error = null

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 638–641why, one step back
638
639 app.use(function (req, res) {640 setImmediate(function () {641 res.sendfile(path.resolve(fixtures, 'name.txt'));

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

line 642why, one step back
642 server.close(cb)

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

lines 643–645why, one step back
643 setTimeout(function () {
644 cb(error)645 }, 10)

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 646–650why, one step back
646 });
647 test.abort();648 });649650 app.use(function (err, req, res, next) {

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

lines 651–652why, one step back
651 error = err
652 next(err)

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 653–654why, one step back
653 });
654

tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2

lines 655–656why, one step back
655 var server = app.listen()
656 var test = request(server).get('/')

Fix issue where "Request aborted" may be logged in res.sendfileDouglas Christopher Wilsonbefore adoption3d10279

line 657why, one step back
657 test.end()

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 658–664why, one step back
658 })
659660 describe('with an absolute path', function(){661 it('should transfer the file', function(done){662 var app = express();663664 app.use(function(req, res){

tests: use path.join instead of concatenationchainhelenbefore adoptioneece385

line 665why, one step back
665 res.sendfile(path.join(__dirname, '/fixtures/user.html'))

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 666–768why, one step back
666 });
667668 request(app)669 .get('/')670 .expect('Content-Type', 'text/html; charset=UTF-8')671 .expect(200, '<p>{{user.name}}</p>', done);672 })673 })674675 describe('with a relative path', function(){676 it('should transfer the file', function(done){677 var app = express();678679 app.use(function(req, res){680 res.sendfile('test/fixtures/user.html');681 });682683 request(app)684 .get('/')685 .expect('Content-Type', 'text/html; charset=UTF-8')686 .expect(200, '<p>{{user.name}}</p>', done);687 })688689 it('should serve relative to "root"', function(done){690 var app = express();691692 app.use(function(req, res){693 res.sendfile('user.html', { root: 'test/fixtures/' });694 });695696 request(app)697 .get('/')698 .expect('Content-Type', 'text/html; charset=UTF-8')699 .expect(200, '<p>{{user.name}}</p>', done);700 })701702 it('should consider ../ malicious when "root" is not set', function(done){703 var app = express();704705 app.use(function(req, res){706 res.sendfile('test/fixtures/foo/../user.html');707 });708709 request(app)710 .get('/')711 .expect(403, done);712 })713714 it('should allow ../ when "root" is set', function(done){715 var app = express();716717 app.use(function(req, res){718 res.sendfile('foo/../user.html', { root: 'test/fixtures' });719 });720721 request(app)722 .get('/')723 .expect(200, done);724 })725726 it('should disallow requesting out of "root"', function(done){727 var app = express();728729 app.use(function(req, res){730 res.sendfile('foo/../../user.html', { root: 'test/fixtures' });731 });732733 request(app)734 .get('/')735 .expect(403, done);736 })737738 it('should next(404) when not found', function(done){739 var app = express()740 , calls = 0;741742 app.use(function(req, res){743 res.sendfile('user.html');744 });745746 app.use(function(req, res){747 assert(0, 'this should not be called');748 });749750 app.use(function(err, req, res, next){751 ++calls;752 next(err);753 });754755 request(app)756 .get('/')757 .end(function(err, res){758 res.statusCode.should.equal(404);759 calls.should.equal(1);760 done();761 });762 })763764 describe('with non-GET', function(){765 it('should still serve', function(done){766 var app = express()767768 app.use(function(req, res){

tests: use path.join instead of concatenationchainhelenbefore adoptioneece385

line 769why, one step back
769 res.sendfile(path.join(__dirname, '/fixtures/name.txt'))

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 770–780why, one step back
770 });
771772 request(app)773 .get('/')774 .expect('tobi', done);775 })776 })777 })778 })779})780

lint: fix broken indentation in testsDouglas Christopher Wilsonbefore adoptionfb3946f

lines 781–783why, one step back
781describe('.sendfile(path, options)', function () {
782 it('should pass options to send module', function (done) {783 var app = express()

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

line 784why, one step back
784

lint: fix broken indentation in testsDouglas Christopher Wilsonbefore adoptionfb3946f

lines 785–787why, one step back
785 app.use(function (req, res) {
786 res.sendfile(path.resolve(fixtures, 'name.txt'), { start: 0, end: 1 })787 })

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

line 788why, one step back
788

lint: fix broken indentation in testsDouglas Christopher Wilsonbefore adoptionfb3946f

line 789why, one step back
789 request(app)

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 790–792why, one step back
790 .get('/')
791 .expect(200, 'to', done)792 })

lint: fix broken indentation in testsDouglas Christopher Wilsonbefore adoptionfb3946f

line 793why, one step back
793})

deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27

lines 794–803why, one step back
794
795function createApp(path, options, fn) {796 var app = express();797798 app.use(function (req, res) {799 res.sendFile(path, options, fn);800 });801802 return app;803}