Skip to content
Myr

Merge tag '3.19.1'

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

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parents 40f7a8e, 0c567b3 · Browse files · 9 files+189 added−92 removed
This commit

State

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

Diff stats

9 files+189 added−92 removed

  • tests:+171 added−89 removed
  • other:+18 added−3 removed

9 files+189 added−92 removed

modified:test/req.fresh.js+1 added-1 removed
modified:test/req.stale.js+1 added-1 removed
modified:test/res.format.js+1 added-1 removed
97 unmodified lines
98 describe('given .default', function(){99 it('should be invoked instead of auto-responding', function(done){100 request(app3)101 .get('/')102 .set('Accept: text/html')102 .set('Accept', 'text/html')103 .expect('default', done);104 })105 })106
92 unmodified lines
modified:test/res.get.js+13 added-7 removed
modified:test/res.links.js+32 added-27 removed
modified:test/res.set.js+50 added-20 removed
12var express = require('../')3 , request = require('supertest')4 , res = express.response;2var express = require('..');3var request = require('supertest');45describe('res', function(){6 describe('.set(field, value)', function(){7 it('should set the response header field', function(done){
8 unmodified lines
16 .expect('Content-Type', 'text/x-foo; charset=utf-8')17 .end(done);18 })1921 it('should coerce to a string', function(){22 res.headers = {};23 res.set('X-Number', 123);24 res.get('X-Number').should.equal('123');20 it('should coerce to a string', function (done) {21 var app = express();2223 app.use(function (req, res) {24 res.set('X-Number', 123);25 res.end(typeof res.get('X-Number'));26 });2728 request(app)29 .get('/')30 .expect('X-Number', '123')31 .expect(200, 'string', done);32 })33 })3435 describe('.set(field, values)', function(){
9 unmodified lines
45 .get('/')46 .expect('["type=ninja","language=javascript"]', done);47 })4842 it('should coerce to an array of strings', function(){43 res.headers = {};44 res.set('X-Numbers', [123, 456]);45 JSON.stringify(res.get('X-Numbers'))46 .should.equal('["123","456"]');49 it('should coerce to an array of strings', function (done) {50 var app = express();5152 app.use(function (req, res) {53 res.set('X-Numbers', [123, 456]);54 res.end(JSON.stringify(res.get('X-Numbers')));55 });5657 request(app)58 .get('/')59 .expect('X-Numbers', '123, 456')60 .expect(200, '["123","456"]', done);61 })6249 it('should not set a charset of one is already set', function () {50 res.headers = {};51 res.set('Content-Type', 'text/html; charset=lol');52 res.get('content-type').should.equal('text/html; charset=lol');63 it('should not set a charset of one is already set', function (done) {64 var app = express();6566 app.use(function (req, res) {67 res.set('Content-Type', 'text/html; charset=lol');68 res.end();69 });7071 request(app)72 .get('/')73 .expect('Content-Type', 'text/html; charset=lol')74 .expect(200, done);75 })76 })7778 describe('.set(object)', function(){
13 unmodified lines
92 .expect('X-Bar', 'baz')93 .end(done);94 })9574 it('should coerce to a string', function(){75 res.headers = {};76 res.set({ 'X-Number': 123 });77 res.get('X-Number').should.equal('123');96 it('should coerce to a string', function (done) {97 var app = express();9899 app.use(function (req, res) {100 res.set({ 'X-Number': 123 });101 res.end(typeof res.get('X-Number'));102 });103104 request(app)105 .get('/')106 .expect('X-Number', '123')107 .expect(200, 'string', done);108 })109 })110})
modified:test/res.vary.js+73 added-32 removed
12var express = require('../')3 , should = require('should');2var assert = require('assert');3var express = require('..');4var request = require('supertest');55function response() {6 var res = Object.create(express.response);7 res._headers = {};8 return res;9}106describe('res.vary()', function(){7 describe('with no arguments', function(){13 it('should not set Vary', function(){14 var res = response();15 res.vary();16 should.not.exist(res.get('Vary'));8 it('should not set Vary', function (done) {9 var app = express();1011 app.use(function (req, res) {12 res.vary();13 res.end();14 });1516 request(app)17 .get('/')18 .expect(shouldNotHaveHeader('Vary'))19 .expect(200, done);20 })21 })2223 describe('with an empty array', function(){21 it('should not set Vary', function(){22 var res = response();23 res.vary([]);24 should.not.exist(res.get('Vary'));24 it('should not set Vary', function (done) {25 var app = express();2627 app.use(function (req, res) {28 res.vary([]);29 res.end();30 });3132 request(app)33 .get('/')34 .expect(shouldNotHaveHeader('Vary'))35 .expect(200, done);36 })37 })3839 describe('with an array', function(){29 it('should set the values', function(){30 var res = response();31 res.vary(['Accept', 'Accept-Language', 'Accept-Encoding']);32 res.get('Vary').should.equal('Accept, Accept-Language, Accept-Encoding');40 it('should set the values', function (done) {41 var app = express();4243 app.use(function (req, res) {44 res.vary(['Accept', 'Accept-Language', 'Accept-Encoding']);45 res.end();46 });4748 request(app)49 .get('/')50 .expect('Vary', 'Accept, Accept-Language, Accept-Encoding')51 .expect(200, done);52 })53 })5455 describe('with a string', function(){37 it('should set the value', function(){38 var res = response();39 res.vary('Accept');40 res.get('Vary').should.equal('Accept');56 it('should set the value', function (done) {57 var app = express();5859 app.use(function (req, res) {60 res.vary('Accept');61 res.end();62 });6364 request(app)65 .get('/')66 .expect('Vary', 'Accept')67 .expect(200, done);68 })69 })7071 describe('when the value is present', function(){45 it('should not add it again', function(){46 var res = response();47 res.vary('Accept');48 res.vary('Accept-Encoding');49 res.vary('Accept-Encoding');50 res.vary('Accept-Encoding');51 res.vary('Accept');52 res.get('Vary').should.equal('Accept, Accept-Encoding');72 it('should not add it again', function (done) {73 var app = express();7475 app.use(function (req, res) {76 res.vary('Accept');77 res.vary('Accept-Encoding');78 res.vary('Accept-Encoding');79 res.vary('Accept-Encoding');80 res.vary('Accept');81 res.end();82 });8384 request(app)85 .get('/')86 .expect('Vary', 'Accept, Accept-Encoding')87 .expect(200, done);88 })89 })90})9192function shouldNotHaveHeader(header) {93 return function (res) {94 assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header);95 };96}
modified:History.md+15 added
1unreleased2==========34 * deps: send@0.11.15 - Fix root path disclosure674.11.0 / 2015-01-138===================910 * Add `res.append(field, val)` to append headers
651 unmodified lines
662 - `app.router()` - returns the app Router instance663 - `app.route()` - Proxy to the app's `Router#route()` method to create a new route664 - Router & Route - public API6656663.19.1 / 2015-01-20667===================668669 * deps: connect@2.28.2670 - deps: body-parser@~1.10.2671 - deps: serve-static@~1.8.1672 * deps: send@0.11.1673 - Fix root path disclosure6746753.19.0 / 2015-01-09676===================677678 * Fix `OPTIONS` responses to include the `HEAD` method property
1938 unmodified lines
modified:package.json+3 added-3 removed
42 unmodified lines
43 "path-to-regexp": "0.1.3",44 "proxy-addr": "~1.0.5",45 "qs": "2.3.3",46 "range-parser": "~1.0.2",47 "send": "0.11.0",47 "send": "0.11.1",48 "serve-static": "~1.8.0",49 "type-is": "~1.5.5",50 "vary": "~1.0.0",51 "cookie": "0.1.2",
1 unmodified line
53 "utils-merge": "1.0.0"54 },55 "devDependencies": {56 "after": "0.8.1",57 "ejs": "2.0.8",57 "ejs": "2.1.4",58 "istanbul": "0.3.5",59 "mocha": "~2.1.0",60 "should": "~4.4.4",60 "should": "~4.6.1",61 "supertest": "~0.15.0",62 "marked": "0.3.2",63 "hjs": "~0.0.6",64 "body-parser": "~1.10.1",
26 unmodified lines