Skip to content
Myr

Revert "add 'etag' option"

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

This reverts commit 6f6eec7d8d929112a37de61c6b78a50bd9f46a73.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 0117464 · Browse files · 3 files+10 added−72 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+10 added−72 removed

  • tests:+0 added−58 removed
  • other:+10 added−14 removed

3 files+10 added−72 removed

modified:lib/application.js-1 removed
45 unmodified lines
4647app.defaultConfiguration = function(){48 // default settings49 this.enable('x-powered-by');50 this.enable('etag');50 this.set('env', process.env.NODE_ENV || 'development');51 debug('booting in %s mode', this.get('env'));5253 // implicit middleware
477 unmodified lines
modified:lib/response.js+10 added-13 removed
80 unmodified lines
81 var req = this.req82 , head = 'HEAD' == req.method83 , len;8485 // settings86 var app = this.app;8785 // allow status / body86 if (2 == arguments.length) {87 // res.send(body, status) backwards compat88 if ('number' != typeof body && 'number' == typeof arguments[1]) {
38 unmodified lines
127 }128129 // ETag support130 // TODO: W/ support134 if (app.settings.etag && len > 1024) {131 if (len > 1024) {132 if (!this.get('ETag')) {133 this.set('ETag', etag(body));134 }135 }
104 unmodified lines
240};241242/**243 * Transfer the file at the given `path`.247 *244 * 245 * Automatically sets the _Content-Type_ response header field.246 * The callback `fn(err)` is invoked when the transfer is complete247 * or when an error occurs. Be sure to check `res.sentHeader`248 * if you wish to attempt responding, as the header and some data
13 unmodified lines
262 *263 * app.get('/user/:uid/photos/:file', function(req, res){264 * var uid = req.params.uid265 * , file = req.params.file;269 *266 * 267 * req.user.mayViewFilesFrom(uid, function(yes){268 * if (yes) {269 * res.sendfile('/uploads/' + uid + '/' + file);270 * } else {
136 unmodified lines
407 * res.format({408 * 'text/plain': function(){409 * res.send('hey');410 * },414 *411 * 412 * 'text/html': function(){413 * res.send('<p>hey</p>');414 * },418 *415 * 416 * 'appliation/json': function(){417 * res.send({ message: 'hey' });418 * }419 * });
4 unmodified lines
424 * res.format({425 * text: function(){426 * res.send('hey');427 * },431 *428 * 429 * html: function(){430 * res.send('<p>hey</p>');431 * },435 *432 * 433 * json: function(){434 * res.send({ message: 'hey' });435 * }436 * });
60 unmodified lines
497 *498 * res.set('Accept', 'application/json');499 * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });500 *504 * Aliased as `res.header()`.501 * Aliased as `res.header()`. 502 *503 * @param {String|Object} field504 * @param {String} val505 * @return {ServerResponse} for chaining506 * @api public507 */508512res.set =509res.set = 510res.header = function(field, val){511 if (2 == arguments.length) {512 this.setHeader(field, '' + val);513 } else {
87 unmodified lines
601 *602 * Mounting:603 *604 * When an application is mounted, and `res.redirect()`608 * is given a path that does _not_ lead with "/". For605 * is given a path that does _not_ lead with "/". For 606 * example suppose a "blog" app is mounted at "/blog",607 * the following redirect would result in "/blog/login":608 *609 * res.redirect('login');
108 unmodified lines
modified:test/res.send.js-58 removed
296 unmodified lines
297 request(app)298 .get('/?callback=foo')299 .expect('{"foo":"bar"}', done);300 })301302 describe('"etag" setting', function(){303 describe('when enabled', function(){304 it('should send ETag ', function(done){305 var app = express();306307 app.use(function(req, res){308 var str = Array(1024 * 2).join('-');309 res.send(str);310 });311312 request(app)313 .get('/')314 .end(function(err, res){315 res.headers.should.have.property('etag', '"-1498647312"');316 done();317 });318 });319 });320321 describe('when disabled', function(){322 it('should send no ETag', function(done){323 var app = express();324325 app.use(function(req, res){326 var str = Array(1024 * 2).join('-');327 res.send(str);328 });329330 app.disable('etag');331332 request(app)333 .get('/')334 .end(function(err, res){335 res.headers.should.not.have.property('etag');336 done();337 });338 });339340 it('should send ETag when manually set', function(done){341 var app = express();342343 app.disable('etag');344345 app.use(function(req, res){346 res.set('etag', 1);347 res.send(200);348 });349350 request(app)351 .get('/')352 .end(function(err, res){353 res.headers.should.have.property('etag');354 done();355 });356 });357 });358 })301})