Skip to content

Commit

Permalink
Merge tag '3.20.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Feb 19, 2015
2 parents ca480d7 + 85755e3 commit 531f024
Show file tree
Hide file tree
Showing 10 changed files with 307 additions and 145 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
language: node_js
node_js:
- "0.10"
- "0.11"
matrix:
allow_failures:
- node_js: "0.11"
fast_finish: true
- "0.12"
sudo: false
script: "npm run-script test-travis"
after_script: "npm install [email protected] && cat ./coverage/lcov.info | coveralls"
41 changes: 41 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
unreleased
==========

* Fix `"trust proxy"` setting to inherit when app is mounted
* Generate `ETag`s for all request responses
- No longer restricted to only responses for `GET` and `HEAD` requests
* Use `content-type` to parse `Content-Type` headers
* deps: [email protected]
* deps: [email protected]
- Always read the stat size from the file
- Fix mutating passed-in `options`
- deps: [email protected]

4.11.2 / 2015-02-01
===================

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

3.20.0 / 2015-02-18
===================

* Fix `"trust proxy"` setting to inherit when app is mounted
* Generate `ETag`s for all request responses
- No longer restricted to only responses for `GET` and `HEAD` requests
* Use `content-type` to parse `Content-Type` headers
* deps: [email protected]
- Use `content-type` to parse `Content-Type` headers
- deps: body-parser@~1.12.0
- deps: compression@~1.4.1
- deps: connect-timeout@~1.6.0
- deps: cookie-parser@~1.3.4
- deps: [email protected]
- deps: csurf@~1.7.0
- deps: errorhandler@~1.3.4
- deps: express-session@~1.10.3
- deps: http-errors@~1.3.1
- deps: response-time@~2.3.0
- deps: serve-index@~1.6.2
- deps: serve-static@~1.9.1
- deps: type-is@~1.6.0
* deps: [email protected]
* deps: [email protected]
- Always read the stat size from the file
- Fix mutating passed-in `options`
- deps: [email protected]

3.19.2 / 2015-02-01
===================

Expand Down
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(The MIT License)

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

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
40 changes: 38 additions & 2 deletions lib/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

/**
* Module dependencies.
* @api private
*/

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

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

/**
* Variable for trust proxy inheritance back-compat
* @api private
*/

var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';

/**
* Initialize the server.
*
Expand Down Expand Up @@ -58,10 +74,23 @@ app.defaultConfiguration = function(){
this.set('subdomain offset', 2);
this.set('trust proxy', false);

// trust proxy inherit back-compat
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
configurable: true,
value: true
});

debug('booting in %s mode', env);

// inherit protos
this.on('mount', function(parent){
this.on('mount', function onmount(parent) {
// inherit trust proxy
if (this.settings[trustProxyDefaultSymbol] === true
&& typeof parent.settings['trust proxy fn'] === 'function') {
delete this.settings['trust proxy'];
delete this.settings['trust proxy fn'];
}

// inherit protos
this.request.__proto__ = parent.request;
this.response.__proto__ = parent.response;
this.engines.__proto__ = parent.engines;
Expand Down Expand Up @@ -327,6 +356,13 @@ app.set = function(setting, val){
case 'trust proxy':
debug('compile trust proxy %s', val);
this.set('trust proxy fn', compileTrust(val));

// trust proxy inherit back-compat
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
configurable: true,
value: false
});

break;
}

Expand Down
25 changes: 15 additions & 10 deletions lib/response.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

/**
* Module dependencies.
* @api private
*/

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

// method check
var isHead = req.method === 'HEAD';

// ETag support
if (len !== undefined && (isHead || req.method === 'GET')) {
var etag = app.get('etag fn');
if (etag && !this.get('ETag')) {
etag = etag(chunk, encoding);
etag && this.set('ETag', etag);
// populate ETag
var etag;
var generateETag = len !== undefined && app.get('etag fn');
if (typeof generateETag === 'function' && !this.get('ETag')) {
if ((etag = generateETag(chunk, encoding))) {
this.set('ETag', etag);
}
}

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

if (isHead) {
if (req.method === 'HEAD') {
// skip body for HEAD
this.end();
} else {
Expand Down
20 changes: 15 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

/**
* Module dependencies.
* @api private
*/

var contentDisposition = require('content-disposition');
var contentType = require('content-type');
var deprecate = require('depd')('express');
var mime = require('send').mime;
var basename = require('path').basename;
var etag = require('etag');
var proxyaddr = require('proxy-addr');
var qs = require('qs');
var querystring = require('querystring');
var typer = require('media-typer');

/**
* Return strong ETag for `body`.
Expand Down Expand Up @@ -258,17 +266,19 @@ exports.compileTrust = function(val) {
* @api private
*/

exports.setCharset = function(type, charset){
if (!type || !charset) return type;
exports.setCharset = function setCharset(type, charset) {
if (!type || !charset) {
return type;
}

// parse type
var parsed = typer.parse(type);
var parsed = contentType.parse(type);

// set charset
parsed.parameters.charset = charset;

// format type
return typer.format(parsed);
return contentType.format(parsed);
};

/**
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@
"dependencies": {
"accepts": "~1.2.3",
"content-disposition": "0.5.0",
"cookie-signature": "1.0.5",
"content-type": "~1.0.1",
"cookie-signature": "1.0.6",
"debug": "~2.1.1",
"depd": "~1.0.0",
"escape-html": "1.0.1",
"etag": "~1.5.1",
"finalhandler": "0.3.3",
"fresh": "0.2.4",
"media-typer": "0.3.0",
"methods": "~1.1.1",
"on-finished": "~2.2.0",
"parseurl": "~1.3.0",
"path-to-regexp": "0.1.3",
"proxy-addr": "~1.0.6",
"qs": "2.3.3",
"range-parser": "~1.0.2",
"send": "0.11.1",
"send": "0.12.1",
"serve-static": "~1.8.1",
"type-is": "~1.5.6",
"vary": "~1.0.0",
Expand All @@ -58,7 +58,7 @@
"istanbul": "0.3.5",
"marked": "0.3.3",
"mocha": "~2.1.0",
"should": "~4.6.2",
"should": "~5.0.0",
"supertest": "~0.15.0",
"hjs": "~0.0.6",
"body-parser": "~1.11.0",
Expand Down
Loading

0 comments on commit 531f024

Please sign in to comment.