Compare commits

...

23 Commits
3.2.2 ... 3.2.5

Author SHA1 Message Date
TJ Holowaychuk
2fe46b3905 Release 3.2.5 2013-05-21 21:01:24 -07:00
TJ Holowaychuk
24974f1f8f update connect 2013-05-21 20:56:08 -07:00
TJ Holowaychuk
e2210b0b92 Merge pull request #1625 from ForbesLindesay/patch-1
Throw a meaningful error when there is no default engine
2013-05-15 08:27:47 -07:00
Forbes Lindesay
30919be2a0 Throw a meaningful error when there is no default engine 2013-05-15 12:39:06 +01:00
TJ Holowaychuk
10b21b41f7 Revert "fix infinite loop when res.send(status) is undefined. Closes #1623"
This reverts commit 28b8a3b5f7.
2013-05-13 13:23:23 -07:00
TJ Holowaychuk
28b8a3b5f7 fix infinite loop when res.send(status) is undefined. Closes #1623 2013-05-13 13:22:31 -07:00
TJ Holowaychuk
c805d80a9b Merge pull request #1592 from bartsqueezy/eb1bbb9
Removing dependency which is no longer supported
2013-05-11 15:36:39 -07:00
TJ Holowaychuk
d876778d22 Merge pull request #1597 from Cauldrath/cookie_version
Version bump for node-cookie
2013-05-11 15:35:30 -07:00
TJ Holowaychuk
412e571600 Merge pull request #1618 from pwmckenna/patch-1
Flush messages exposed to locals *after* the view has the chance to proces...
2013-05-11 15:26:22 -07:00
TJ Holowaychuk
3296ed9cb3 change generation of ETags with res.send() to GET requests only. Closes #1619
if for some reason this is not ideal for your use-case please let me know and comment in the issue
2013-05-10 14:43:59 -07:00
Patrick Williams
91835e6816 Flush messages exposed to locals after the view has the chance to process them. 2013-05-10 09:05:37 -06:00
TJ Holowaychuk
f976625281 Release 3.2.4 2013-05-09 09:17:48 -07:00
TJ Holowaychuk
028d9d8a0c Merge pull request #1598 from colynb/patch-1
the file is hosts not vhosts
2013-05-09 09:12:54 -07:00
TJ Holowaychuk
8559c0e2a4 fix req.subdomains when no Host is present 2013-05-09 09:10:52 -07:00
TJ Holowaychuk
06ead58240 fix req.host when no Host is present, return undefined 2013-05-09 09:06:11 -07:00
TJ Holowaychuk
28ca1b5221 add req.host tests 2013-05-09 09:03:52 -07:00
TJ Holowaychuk
6d872e6693 remove qs dep 2013-05-07 07:58:54 -07:00
TJ Holowaychuk
0b09c8981f Release 3.2.3 2013-05-07 07:55:06 -07:00
TJ Holowaychuk
a1d5676ecb update connect / qs 2013-05-07 07:54:48 -07:00
colynb
69453ff889 the file is hosts not vhosts 2013-05-01 16:27:29 -07:00
Benjamin Hanes
28752cc3c0 Version bump for node-cookie 2013-05-01 15:25:14 -04:00
Steve Bartnesky
5fa685b602 removing github-flavored-markdown as a dependency as it is no longer supported. switch to use marked instead 2013-04-29 09:12:29 -05:00
Steve Bartnesky
eb1bbb92c0 removing github-flavored-markdown as a dependency as it is no longer supported. switch to use marked instead 2013-04-29 08:59:52 -05:00
13 changed files with 111 additions and 26 deletions

View File

@@ -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
==================

View File

@@ -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();

View File

@@ -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');
}
}

View File

@@ -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

View File

@@ -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();

View File

@@ -20,7 +20,7 @@ exports = module.exports = createApplication;
* Framework version.
*/
exports.version = '3.2.2';
exports.version = '3.2.5';
/**
* Expose mime.

View File

@@ -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];
});

View File

@@ -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));
}

View File

@@ -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);

View File

@@ -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
View 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);
})
})
})

View File

@@ -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){

View File

@@ -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();