mirror of
https://github.com/expressjs/express.git
synced 2026-02-26 08:45:36 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fe46b3905 | ||
|
|
24974f1f8f | ||
|
|
e2210b0b92 | ||
|
|
30919be2a0 | ||
|
|
10b21b41f7 | ||
|
|
28b8a3b5f7 | ||
|
|
c805d80a9b | ||
|
|
d876778d22 | ||
|
|
412e571600 | ||
|
|
3296ed9cb3 | ||
|
|
91835e6816 | ||
|
|
f976625281 | ||
|
|
028d9d8a0c | ||
|
|
8559c0e2a4 | ||
|
|
06ead58240 | ||
|
|
28ca1b5221 | ||
|
|
6d872e6693 | ||
|
|
0b09c8981f | ||
|
|
a1d5676ecb | ||
|
|
69453ff889 | ||
|
|
28752cc3c0 | ||
|
|
5fa685b602 | ||
|
|
eb1bbb92c0 |
19
History.md
19
History.md
@@ -1,4 +1,23 @@
|
||||
|
||||
3.2.5 / 2013-05-21
|
||||
==================
|
||||
|
||||
* update connect
|
||||
* update node-cookie
|
||||
* add: throw a meaningful error when there is no default engine
|
||||
* change generation of ETags with res.send() to GET requests only. Closes #1619
|
||||
|
||||
3.2.4 / 2013-05-09
|
||||
==================
|
||||
|
||||
* fix `req.subdomains` when no Host is present
|
||||
* fix `req.host` when no Host is present, return undefined
|
||||
|
||||
3.2.3 / 2013-05-07
|
||||
==================
|
||||
|
||||
* update connect / qs
|
||||
|
||||
3.2.2 / 2013-05-03
|
||||
==================
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
var express = require('../..')
|
||||
, fs = require('fs')
|
||||
, md = require('github-flavored-markdown').parse;
|
||||
, md = require('marked').parse;
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
var express = require('../..');
|
||||
|
||||
var app = module.exports = express();
|
||||
@@ -58,10 +57,10 @@ app.use(function(req, res, next){
|
||||
});
|
||||
*/
|
||||
|
||||
next();
|
||||
// empty or "flush" the messages so they
|
||||
// don't build up
|
||||
req.session.messages = [];
|
||||
next();
|
||||
});
|
||||
|
||||
// load controllers
|
||||
@@ -90,4 +89,4 @@ app.use(function(req, res, next){
|
||||
if (!module.parent) {
|
||||
app.listen(3000);
|
||||
console.log('\n listening on port 3000\n');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
@@ -6,7 +5,7 @@
|
||||
var express = require('../..');
|
||||
|
||||
/*
|
||||
edit /etc/vhosts:
|
||||
edit /etc/hosts:
|
||||
|
||||
127.0.0.1 foo.example.com
|
||||
127.0.0.1 bar.example.com
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
var express = require('../../')
|
||||
, http = require('http')
|
||||
, GithubView = require('./github-view')
|
||||
, md = require('github-flavored-markdown').parse;
|
||||
, md = require('marked').parse;
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ exports = module.exports = createApplication;
|
||||
* Framework version.
|
||||
*/
|
||||
|
||||
exports.version = '3.2.2';
|
||||
exports.version = '3.2.5';
|
||||
|
||||
/**
|
||||
* Expose mime.
|
||||
|
||||
@@ -445,7 +445,7 @@ req.__defineGetter__('auth', function(){
|
||||
|
||||
req.__defineGetter__('subdomains', function(){
|
||||
var offset = this.app.get('subdomain offset');
|
||||
return this.get('Host')
|
||||
return (this.host || '')
|
||||
.split('.')
|
||||
.reverse()
|
||||
.slice(offset);
|
||||
@@ -473,6 +473,7 @@ req.__defineGetter__('host', function(){
|
||||
var trustProxy = this.app.get('trust proxy');
|
||||
var host = trustProxy && this.get('X-Forwarded-Host');
|
||||
host = host || this.get('Host');
|
||||
if (!host) return;
|
||||
return host.split(':')[0];
|
||||
});
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ res.links = function(links){
|
||||
*/
|
||||
|
||||
res.send = function(body){
|
||||
var req = this.req
|
||||
, head = 'HEAD' == req.method
|
||||
, len;
|
||||
var req = this.req;
|
||||
var head = 'HEAD' == req.method;
|
||||
var len;
|
||||
|
||||
// allow status / body
|
||||
if (2 == arguments.length) {
|
||||
@@ -128,7 +128,7 @@ res.send = function(body){
|
||||
|
||||
// ETag support
|
||||
// TODO: W/ support
|
||||
if (len > 1024) {
|
||||
if (len > 1024 && 'GET' == req.method) {
|
||||
if (!this.get('ETag')) {
|
||||
this.set('ETag', etag(body));
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ function View(name, options) {
|
||||
var engines = options.engines;
|
||||
this.defaultEngine = options.defaultEngine;
|
||||
var ext = this.ext = extname(name);
|
||||
if (!ext && !this.defaultEngine) throw new Error('No default engine was specified and no extension was provided.');
|
||||
if (!ext) name += (ext = this.ext = ('.' != this.defaultEngine[0] ? '.' : '') + this.defaultEngine);
|
||||
this.engine = engines[ext] || (engines[ext] = require(ext.slice(1)).__express);
|
||||
this.path = this.lookup(name);
|
||||
|
||||
11
package.json
11
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "express",
|
||||
"description": "Sinatra inspired web development framework",
|
||||
"version": "3.2.2",
|
||||
"version": "3.2.5",
|
||||
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
||||
"contributors": [
|
||||
{
|
||||
@@ -22,18 +22,17 @@
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"connect": "2.7.8",
|
||||
"connect": "2.7.10",
|
||||
"commander": "0.6.1",
|
||||
"range-parser": "0.0.4",
|
||||
"mkdirp": "0.3.4",
|
||||
"cookie": "0.0.5",
|
||||
"cookie": "0.1.0",
|
||||
"buffer-crc32": "0.2.1",
|
||||
"fresh": "0.1.0",
|
||||
"methods": "0.0.1",
|
||||
"send": "0.1.0",
|
||||
"cookie-signature": "1.0.1",
|
||||
"debug": "*",
|
||||
"qs": "0.6.3"
|
||||
"debug": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ejs": "*",
|
||||
@@ -43,7 +42,7 @@
|
||||
"stylus": "*",
|
||||
"should": "*",
|
||||
"connect-redis": "*",
|
||||
"github-flavored-markdown": "*",
|
||||
"marked": "*",
|
||||
"supertest": "0.6.0"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
34
test/req.host.js
Normal file
34
test/req.host.js
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
var express = require('../')
|
||||
, request = require('./support/http')
|
||||
, assert = require('assert');
|
||||
|
||||
describe('req', function(){
|
||||
describe('.host', function(){
|
||||
it('should return the Host when present', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
res.end(req.host);
|
||||
});
|
||||
|
||||
request(app)
|
||||
.post('/')
|
||||
.set('Host', 'example.com')
|
||||
.expect('example.com', done);
|
||||
})
|
||||
|
||||
it('should return undefined otherwise', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
req.headers.host = null;
|
||||
res.end(String(req.host));
|
||||
});
|
||||
|
||||
request(app)
|
||||
.post('/')
|
||||
.expect('undefined', done);
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -34,6 +34,21 @@ describe('req', function(){
|
||||
})
|
||||
})
|
||||
|
||||
describe('with no host', function(){
|
||||
it('should return an empty array', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
req.headers.host = null;
|
||||
res.send(req.subdomains);
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('[]', done);
|
||||
})
|
||||
})
|
||||
|
||||
describe('when subdomain offset is set', function(){
|
||||
describe('when subdomain offset is zero', function(){
|
||||
it('should return an array with the whole domain', function(done){
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
var express = require('../')
|
||||
, request = require('./support/http');
|
||||
, request = require('./support/http')
|
||||
, assert = require('assert');
|
||||
|
||||
describe('res', function(){
|
||||
describe('.send(null)', function(){
|
||||
@@ -16,7 +17,7 @@ describe('res', function(){
|
||||
.expect('', done);
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('.send(undefined)', function(){
|
||||
it('should set body to ""', function(done){
|
||||
var app = express();
|
||||
@@ -45,7 +46,7 @@ describe('res', function(){
|
||||
.expect(201, done);
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('.send(code, body)', function(){
|
||||
it('should set .statusCode and body', function(done){
|
||||
var app = express();
|
||||
@@ -107,7 +108,24 @@ describe('res', function(){
|
||||
.expect('ETag', '"-1498647312"')
|
||||
.end(done);
|
||||
})
|
||||
|
||||
|
||||
it('should not set ETag for non-GET/HEAD', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
var str = Array(1024 * 2).join('-');
|
||||
res.send(str);
|
||||
});
|
||||
|
||||
request(app)
|
||||
.post('/')
|
||||
.end(function(err, res){
|
||||
if (err) return done(err);
|
||||
assert(!res.header.etag, 'has an ETag');
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
||||
it('should not override Content-Type', function(done){
|
||||
var app = express();
|
||||
|
||||
@@ -122,7 +140,7 @@ describe('res', function(){
|
||||
.expect(200, done);
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('.send(Buffer)', function(){
|
||||
it('should send as octet-stream', function(done){
|
||||
var app = express();
|
||||
@@ -172,7 +190,7 @@ describe('res', function(){
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('.send(Object)', function(){
|
||||
it('should send as application/json', function(done){
|
||||
var app = express();
|
||||
@@ -224,7 +242,7 @@ describe('res', function(){
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('when .statusCode is 304', function(){
|
||||
it('should strip Content-* fields, Transfer-Encoding field, and body', function(done){
|
||||
var app = express();
|
||||
|
||||
Reference in New Issue
Block a user