Skip to content

Commit 531f024

Browse files
committed
Merge tag '3.20.0'
2 parents ca480d7 + 85755e3 commit 531f024

10 files changed

+307
-145
lines changed

.travis.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
language: node_js
22
node_js:
33
- "0.10"
4-
- "0.11"
5-
matrix:
6-
allow_failures:
7-
- node_js: "0.11"
8-
fast_finish: true
4+
- "0.12"
5+
sudo: false
96
script: "npm run-script test-travis"
107
after_script: "npm install [email protected] && cat ./coverage/lcov.info | coveralls"

History.md

+41
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
unreleased
2+
==========
3+
4+
* Fix `"trust proxy"` setting to inherit when app is mounted
5+
* Generate `ETag`s for all request responses
6+
- No longer restricted to only responses for `GET` and `HEAD` requests
7+
* Use `content-type` to parse `Content-Type` headers
8+
9+
10+
- Always read the stat size from the file
11+
- Fix mutating passed-in `options`
12+
13+
114
4.11.2 / 2015-02-01
215
===================
316

@@ -678,6 +691,34 @@
678691
- `app.route()` - Proxy to the app's `Router#route()` method to create a new route
679692
- Router & Route - public API
680693

694+
3.20.0 / 2015-02-18
695+
===================
696+
697+
* Fix `"trust proxy"` setting to inherit when app is mounted
698+
* Generate `ETag`s for all request responses
699+
- No longer restricted to only responses for `GET` and `HEAD` requests
700+
* Use `content-type` to parse `Content-Type` headers
701+
702+
- Use `content-type` to parse `Content-Type` headers
703+
- deps: body-parser@~1.12.0
704+
- deps: compression@~1.4.1
705+
- deps: connect-timeout@~1.6.0
706+
- deps: cookie-parser@~1.3.4
707+
708+
- deps: csurf@~1.7.0
709+
- deps: errorhandler@~1.3.4
710+
- deps: express-session@~1.10.3
711+
- deps: http-errors@~1.3.1
712+
- deps: response-time@~2.3.0
713+
- deps: serve-index@~1.6.2
714+
- deps: serve-static@~1.9.1
715+
- deps: type-is@~1.6.0
716+
717+
718+
- Always read the stat size from the file
719+
- Fix mutating passed-in `options`
720+
721+
681722
3.19.2 / 2015-02-01
682723
===================
683724

LICENSE

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
(The MIT License)
22

33
Copyright (c) 2009-2014 TJ Holowaychuk <[email protected]>
4+
Copyright (c) 2013-2014 Roman Shtylman <[email protected]>
5+
Copyright (c) 2014-2015 Douglas Christopher Wilson <[email protected]>
46

57
Permission is hereby granted, free of charge, to any person obtaining
68
a copy of this software and associated documentation files (the

lib/application.js

+38-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
/*!
2+
* express
3+
* Copyright(c) 2009-2013 TJ Holowaychuk
4+
* Copyright(c) 2013 Roman Shtylman
5+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
6+
* MIT Licensed
7+
*/
8+
19
/**
210
* Module dependencies.
11+
* @api private
312
*/
413

514
var finalhandler = require('finalhandler');
@@ -25,6 +34,13 @@ var slice = Array.prototype.slice;
2534

2635
var app = exports = module.exports = {};
2736

37+
/**
38+
* Variable for trust proxy inheritance back-compat
39+
* @api private
40+
*/
41+
42+
var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';
43+
2844
/**
2945
* Initialize the server.
3046
*
@@ -58,10 +74,23 @@ app.defaultConfiguration = function(){
5874
this.set('subdomain offset', 2);
5975
this.set('trust proxy', false);
6076

77+
// trust proxy inherit back-compat
78+
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
79+
configurable: true,
80+
value: true
81+
});
82+
6183
debug('booting in %s mode', env);
6284

63-
// inherit protos
64-
this.on('mount', function(parent){
85+
this.on('mount', function onmount(parent) {
86+
// inherit trust proxy
87+
if (this.settings[trustProxyDefaultSymbol] === true
88+
&& typeof parent.settings['trust proxy fn'] === 'function') {
89+
delete this.settings['trust proxy'];
90+
delete this.settings['trust proxy fn'];
91+
}
92+
93+
// inherit protos
6594
this.request.__proto__ = parent.request;
6695
this.response.__proto__ = parent.response;
6796
this.engines.__proto__ = parent.engines;
@@ -327,6 +356,13 @@ app.set = function(setting, val){
327356
case 'trust proxy':
328357
debug('compile trust proxy %s', val);
329358
this.set('trust proxy fn', compileTrust(val));
359+
360+
// trust proxy inherit back-compat
361+
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
362+
configurable: true,
363+
value: false
364+
});
365+
330366
break;
331367
}
332368

lib/response.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
/*!
2+
* express
3+
* Copyright(c) 2009-2013 TJ Holowaychuk
4+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
5+
* MIT Licensed
6+
*/
7+
18
/**
29
* Module dependencies.
10+
* @api private
311
*/
412

513
var contentDisposition = require('content-disposition');
@@ -159,15 +167,12 @@ res.send = function send(body) {
159167
this.set('Content-Length', len);
160168
}
161169

162-
// method check
163-
var isHead = req.method === 'HEAD';
164-
165-
// ETag support
166-
if (len !== undefined && (isHead || req.method === 'GET')) {
167-
var etag = app.get('etag fn');
168-
if (etag && !this.get('ETag')) {
169-
etag = etag(chunk, encoding);
170-
etag && this.set('ETag', etag);
170+
// populate ETag
171+
var etag;
172+
var generateETag = len !== undefined && app.get('etag fn');
173+
if (typeof generateETag === 'function' && !this.get('ETag')) {
174+
if ((etag = generateETag(chunk, encoding))) {
175+
this.set('ETag', etag);
171176
}
172177
}
173178

@@ -182,7 +187,7 @@ res.send = function send(body) {
182187
chunk = '';
183188
}
184189

185-
if (isHead) {
190+
if (req.method === 'HEAD') {
186191
// skip body for HEAD
187192
this.end();
188193
} else {

lib/utils.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
/*!
2+
* express
3+
* Copyright(c) 2009-2013 TJ Holowaychuk
4+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
5+
* MIT Licensed
6+
*/
7+
18
/**
29
* Module dependencies.
10+
* @api private
311
*/
412

513
var contentDisposition = require('content-disposition');
14+
var contentType = require('content-type');
615
var deprecate = require('depd')('express');
716
var mime = require('send').mime;
817
var basename = require('path').basename;
918
var etag = require('etag');
1019
var proxyaddr = require('proxy-addr');
1120
var qs = require('qs');
1221
var querystring = require('querystring');
13-
var typer = require('media-typer');
1422

1523
/**
1624
* Return strong ETag for `body`.
@@ -258,17 +266,19 @@ exports.compileTrust = function(val) {
258266
* @api private
259267
*/
260268

261-
exports.setCharset = function(type, charset){
262-
if (!type || !charset) return type;
269+
exports.setCharset = function setCharset(type, charset) {
270+
if (!type || !charset) {
271+
return type;
272+
}
263273

264274
// parse type
265-
var parsed = typer.parse(type);
275+
var parsed = contentType.parse(type);
266276

267277
// set charset
268278
parsed.parameters.charset = charset;
269279

270280
// format type
271-
return typer.format(parsed);
281+
return contentType.format(parsed);
272282
};
273283

274284
/**

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@
2929
"dependencies": {
3030
"accepts": "~1.2.3",
3131
"content-disposition": "0.5.0",
32-
"cookie-signature": "1.0.5",
32+
"content-type": "~1.0.1",
33+
"cookie-signature": "1.0.6",
3334
"debug": "~2.1.1",
3435
"depd": "~1.0.0",
3536
"escape-html": "1.0.1",
3637
"etag": "~1.5.1",
3738
"finalhandler": "0.3.3",
3839
"fresh": "0.2.4",
39-
"media-typer": "0.3.0",
4040
"methods": "~1.1.1",
4141
"on-finished": "~2.2.0",
4242
"parseurl": "~1.3.0",
4343
"path-to-regexp": "0.1.3",
4444
"proxy-addr": "~1.0.6",
4545
"qs": "2.3.3",
4646
"range-parser": "~1.0.2",
47-
"send": "0.11.1",
47+
"send": "0.12.1",
4848
"serve-static": "~1.8.1",
4949
"type-is": "~1.5.6",
5050
"vary": "~1.0.0",
@@ -58,7 +58,7 @@
5858
"istanbul": "0.3.5",
5959
"marked": "0.3.3",
6060
"mocha": "~2.1.0",
61-
"should": "~4.6.2",
61+
"should": "~5.0.0",
6262
"supertest": "~0.15.0",
6363
"hjs": "~0.0.6",
6464
"body-parser": "~1.11.0",

0 commit comments

Comments
 (0)