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
Provenance
- Commit
82689d6- Tree
62250ee- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent 1
40f7a8e- Parent 2
0c567b3
9 files changed+189 added−92 removed
modified:test/req.fresh.js+1 added-1 removed
35 unmodified lines363738394040414243445 unmodified lines35 unmodified lines it('should return false without response headers', function(done){ var app = express();
app.use(function(req, res){ res._headers = undefined; res._headers = null; res.send(req.fresh); });
request(app)5 unmodified linesmodified:test/req.stale.js+1 added-1 removed
35 unmodified lines363738394040414243445 unmodified lines35 unmodified lines it('should return true without response headers', function(done){ var app = express();
app.use(function(req, res){ res._headers = undefined; res._headers = null; res.send(req.stale); });
request(app)5 unmodified linesmodified:test/res.format.js+1 added-1 removed
97 unmodified lines98 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 linesmodified:test/res.get.js+13 added-7 removed
1232345678910117891011121314151617181920
var express = require('../') , res = express.response;var express = require('..');var request = require('supertest');
describe('res', function(){ describe('.get(field)', function(){ it('should get the response header field', function(){ res.setHeader('Content-Type', 'text/x-foo'); res.get('Content-Type').should.equal('text/x-foo'); res.get('Content-type').should.equal('text/x-foo'); res.get('content-type').should.equal('text/x-foo'); it('should get the response header field', function (done) { var app = express();
app.use(function (req, res) { res.setHeader('Content-Type', 'text/x-foo'); res.send(res.get('Content-Type')); });
request(app) .get('/') .expect(200, 'text/x-foo', done); }) })})modified:test/res.links.js+32 added-27 removed
12323456789106789121314151011121314151617181920211819202122232425262728242526272829303132303133343536373839343536373840414243444546
var express = require('../') , res = express.response;var express = require('..');var request = require('supertest');
describe('res', function(){
beforeEach(function() { res.removeHeader('link'); });
describe('.links(obj)', function(){ it('should set Link header field', function (done) { var app = express();
it('should set Link header field', function(){ res.links({ next: 'http://api.example.com/users?page=2', last: 'http://api.example.com/users?page=5' app.use(function (req, res) { res.links({ next: 'http://api.example.com/users?page=2', last: 'http://api.example.com/users?page=5' }); res.end(); });
res.get('link') .should.equal( '<http://api.example.com/users?page=2>; rel="next", ' + '<http://api.example.com/users?page=5>; rel="last"'); request(app) .get('/') .expect('Link', '<http://api.example.com/users?page=2>; rel="next", <http://api.example.com/users?page=5>; rel="last"') .expect(200, done); })
it('should set Link header field for multiple calls', function() { res.links({ next: 'http://api.example.com/users?page=2', last: 'http://api.example.com/users?page=5' }); it('should set Link header field for multiple calls', function (done) { var app = express();
app.use(function (req, res) { res.links({ next: 'http://api.example.com/users?page=2', last: 'http://api.example.com/users?page=5' });
res.links({ prev: 'http://api.example.com/users?page=1', res.links({ prev: 'http://api.example.com/users?page=1' });
res.end(); });
res.get('link') .should.equal( '<http://api.example.com/users?page=2>; rel="next", ' + '<http://api.example.com/users?page=5>; rel="last", ' + '<http://api.example.com/users?page=1>; rel="prev"'); request(app) .get('/') .expect('Link', '<http://api.example.com/users?page=2>; rel="next", <http://api.example.com/users?page=5>; rel="last", <http://api.example.com/users?page=1>; rel="prev"') .expect(200, done); }) })})modified:test/res.set.js+50 added-20 removed
1 2-var express = require('../')3- , request = require('supertest')4- , res = express.response;2+var express = require('..');3+var request = require('supertest');4 5 describe('res', function(){6 describe('.set(field, value)', function(){7 it('should set the response header field', function(done){8 unmodified lines16 .expect('Content-Type', 'text/x-foo; charset=utf-8')17 .end(done);18 })19 21- 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();22+23+ app.use(function (req, res) {24+ res.set('X-Number', 123);25+ res.end(typeof res.get('X-Number'));26+ });27+28+ request(app)29+ .get('/')30+ .expect('X-Number', '123')31+ .expect(200, 'string', done);32 })33 })34 35 describe('.set(field, values)', function(){9 unmodified lines45 .get('/')46 .expect('["type=ninja","language=javascript"]', done);47 })48 42- 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();51+52+ app.use(function (req, res) {53+ res.set('X-Numbers', [123, 456]);54+ res.end(JSON.stringify(res.get('X-Numbers')));55+ });56+57+ request(app)58+ .get('/')59+ .expect('X-Numbers', '123, 456')60+ .expect(200, '["123","456"]', done);61 })62 49- 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();65+66+ app.use(function (req, res) {67+ res.set('Content-Type', 'text/html; charset=lol');68+ res.end();69+ });70+71+ request(app)72+ .get('/')73+ .expect('Content-Type', 'text/html; charset=lol')74+ .expect(200, done);75 })76 })77 78 describe('.set(object)', function(){13 unmodified lines92 .expect('X-Bar', 'baz')93 .end(done);94 })95 74- 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();98+99+ app.use(function (req, res) {100+ res.set({ 'X-Number': 123 });101+ res.end(typeof res.get('X-Number'));102+ });103+104+ 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
1 2-var express = require('../')3- , should = require('should');2+var assert = require('assert');3+var express = require('..');4+var request = require('supertest');5 5-function response() {6- var res = Object.create(express.response);7- res._headers = {};8- return res;9-}10-6 describe('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();10+11+ app.use(function (req, res) {12+ res.vary();13+ res.end();14+ });15+16+ request(app)17+ .get('/')18+ .expect(shouldNotHaveHeader('Vary'))19+ .expect(200, done);20 })21 })22 23 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();26+27+ app.use(function (req, res) {28+ res.vary([]);29+ res.end();30+ });31+32+ request(app)33+ .get('/')34+ .expect(shouldNotHaveHeader('Vary'))35+ .expect(200, done);36 })37 })38 39 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();42+43+ app.use(function (req, res) {44+ res.vary(['Accept', 'Accept-Language', 'Accept-Encoding']);45+ res.end();46+ });47+48+ request(app)49+ .get('/')50+ .expect('Vary', 'Accept, Accept-Language, Accept-Encoding')51+ .expect(200, done);52 })53 })54 55 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();58+59+ app.use(function (req, res) {60+ res.vary('Accept');61+ res.end();62+ });63+64+ request(app)65+ .get('/')66+ .expect('Vary', 'Accept')67+ .expect(200, done);68 })69 })70 71 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();74+75+ 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+ });83+84+ request(app)85+ .get('/')86+ .expect('Vary', 'Accept, Accept-Encoding')87+ .expect(200, done);88 })89 })90 })91+92+function 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
1+unreleased2+==========3+4+ * deps: send@0.11.15+ - Fix root path disclosure6+7 4.11.0 / 2015-01-138 ===================9 10 * Add `res.append(field, val)` to append headers651 unmodified lines662 - `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 API665 666+3.19.1 / 2015-01-20667+===================668+669+ * 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 disclosure674+675 3.19.0 / 2015-01-09676 ===================677 678 * Fix `OPTIONS` responses to include the `HEAD` method property1938 unmodified linesmodified:package.json+3 added-3 removed
42 unmodified lines43 "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 line53 "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