Skip to content
Myr

Removed `res.header(field, value)`

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 c44f018 · Browse files · 4 files+5 added−82 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+5 added−82 removed

  • tests:+2 added−64 removed
  • other:+3 added−18 removed

4 files+5 added−82 removed

modified:lib/router/index.js+1 added-1 removed
295 unmodified lines
296297Router.prototype._options = function(req, res){298 var path = parse(req.url).pathname299 , body = this._optionsFor(path).join(',');300 res.header('Allow', body).send(body);300 res.set('Allow', body).send(body);301};302303/**304 * Return an array of HTTP verbs or "options" for `path`.
112 unmodified lines
modified:lib/response.js+2 added-17 removed
339 unmodified lines
340 return this.getHeader(field);341};342343/**344 * Set or get response header `field` with optional `val`.345 *346 * @param {String} name347 * @param {String} val348 * @return {ServerResponse} for chaining349 * @api public350 */351352res.header = function(field, val){353 if (1 == arguments.length) return this.getHeader(field);354 this.setHeader(field, val);355 return this;356};357358/**344 * Clear cookie `name`.345 *346 * @param {String} name347 * @param {Object} options
103 unmodified lines
451 url = arguments[1];452 }453454 // setup redirect map470 var map = { back: req.header('Referrer', '/') };455 var map = { back: req.get('Referrer') || '/' };456457 // perform redirect458 url = map[url] || url;459
9 unmodified lines
469 url = path + '/' + url;470 }471472 // Absolute488 var host = req.header('Host');473 var host = req.get('Host');474 url = req.protocol + '://' + host + url;475 }476477 // Support text/{plain,html} by default
84 unmodified lines
deleted:test/res.header.js-62 removed
modified:test/res.send.js+2 added-2 removed
93 unmodified lines
94 it('should not override Content-Type', function(done){95 var app = express();9697 app.use(function(req, res){98 res.header('Content-Type', 'text/plain').send('hey');98 res.set('Content-Type', 'text/plain').send('hey');99 });100101 request(app)102 .get('/')
27 unmodified lines
130 it('should not override Content-Type', function(done){131 var app = express();132133 app.use(function(req, res){134 res.header('Content-Type', 'text/plain').send(new Buffer('hey'));134 res.set('Content-Type', 'text/plain').send(new Buffer('hey'));135 });136137 request(app)138 .get('/')
82 unmodified lines