Compare commits

...

19 Commits
3.2.6 ... 3.3.2

Author SHA1 Message Date
TJ Holowaychuk
52440955e6 Release 3.3.2 2013-07-03 11:25:54 -07:00
TJ Holowaychuk
c2f3d6ce2b update connect 2013-07-03 11:25:15 -07:00
TJ Holowaychuk
be858f5d07 update send 2013-07-03 11:24:31 -07:00
TJ Holowaychuk
ba5c48aa86 remove .version export 2013-06-27 08:38:53 -07:00
TJ Holowaychuk
320d7807a9 Release 3.3.1 2013-06-27 08:32:37 -07:00
TJ Holowaychuk
6650a312b7 update connect 2013-06-27 08:32:20 -07:00
TJ Holowaychuk
832c3b3744 Release 3.3.0 2013-06-26 10:07:34 -07:00
TJ Holowaychuk
76691bfd6b update connect 2013-06-26 10:05:40 -07:00
TJ Holowaychuk
29fe5ea785 Merge pull request #1657 from ralphtheninja/master
use send 0.1.1 to get rid of npm warning during install
2013-06-26 09:54:24 -07:00
Lars-Magnus Skog
52a820113f use send 0.1.1 to get rid of npm warning 2013-06-23 00:49:20 +02:00
TJ Holowaychuk
aec3428489 Merge pull request #1650 from printercu/master
move .app to req's & res's prototypes
2013-06-11 12:39:59 -07:00
TJ Holowaychuk
a10f695b6f pin jade dev dep so tests do not break 2013-06-11 12:24:17 -07:00
Max Melentiev
a3c9eacaf1 move .app to req's & res's prototypes 2013-06-11 19:42:30 +04:00
TJ Holowaychuk
19d685b152 return actual booleans from req.accept* functions 2013-06-06 13:47:18 -07:00
TJ Holowaychuk
8ab44081d4 add support for multiple X-Forwarded-Proto values. Closes #1646 2013-06-05 12:05:45 -07:00
TJ Holowaychuk
0431d22822 add req.secure tests 2013-06-05 11:59:47 -07:00
TJ Holowaychuk
138d74aefa remove charset from json responses. Closes #1631 2013-06-05 11:51:59 -07:00
TJ Holowaychuk
28562b2cf8 Merge pull request #1643 from jonjenkins/master
Fixed issue with callback querystring failure
2013-06-03 14:52:49 -07:00
Jenkins
2f19b4fefc Corrected callback crashing app when array 2013-05-26 21:35:52 -05:00
11 changed files with 130 additions and 39 deletions

View File

@@ -1,4 +1,25 @@
3.3.2 / 2013-07-03
==================
* update connect
* update send
* remove .version export
3.3.1 / 2013-06-27
==================
* update connect
3.3.0 / 2013-06-26
==================
* update connect
* add support for multiple X-Forwarded-Proto values. Closes #1646
* change: remove charset from json responses. Closes #1631
* change: return actual booleans from req.accept* functions
* fix jsonp callback array throw
3.2.6 / 2013-06-02
==================

View File

@@ -117,7 +117,6 @@ app.use = function(route, fn){
fn = function(req, res, next) {
var orig = req.app;
app.handle(req, res, function(err){
req.app = res.app = orig;
req.__proto__ = orig.request;
res.__proto__ = orig.response;
next(err);

View File

@@ -16,12 +16,6 @@ var connect = require('connect')
exports = module.exports = createApplication;
/**
* Framework version.
*/
exports.version = '3.2.5';
/**
* Expose mime.
*/
@@ -38,8 +32,8 @@ exports.mime = connect.mime;
function createApplication() {
var app = connect();
utils.merge(app, proto);
app.request = { __proto__: req };
app.response = { __proto__: res };
app.request = { __proto__: req, app: app };
app.response = { __proto__: res, app: app };
app.init();
return app;
}

View File

@@ -17,7 +17,6 @@ var utils = require('./utils');
exports.init = function(app){
return function expressInit(req, res, next){
req.app = res.app = app;
if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
req.res = res;
res.req = req;

View File

@@ -110,7 +110,7 @@ req.accepts = function(type){
*/
req.acceptsEncoding = function(encoding){
return ~this.acceptedEncodings.indexOf(encoding);
return !! ~this.acceptedEncodings.indexOf(encoding);
};
/**
@@ -125,7 +125,7 @@ req.acceptsEncoding = function(encoding){
req.acceptsCharset = function(charset){
var accepted = this.acceptedCharsets;
return accepted.length
? ~accepted.indexOf(charset)
? !! ~accepted.indexOf(charset)
: true;
};
@@ -141,7 +141,7 @@ req.acceptsCharset = function(charset){
req.acceptsLanguage = function(lang){
var accepted = this.acceptedLanguages;
return accepted.length
? ~accepted.indexOf(lang)
? !! ~accepted.indexOf(lang)
: true;
};
@@ -345,11 +345,10 @@ req.is = function(type){
req.__defineGetter__('protocol', function(){
var trustProxy = this.app.get('trust proxy');
return this.connection.encrypted
? 'https'
: trustProxy
? (this.get('X-Forwarded-Proto') || 'http')
: 'http';
if (this.connection.encrypted) return 'https';
if (!trustProxy) return 'http';
var proto = this.get('X-Forwarded-Proto') || 'http';
return proto.split(/\s*,\s*/)[0];
});
/**

View File

@@ -185,7 +185,6 @@ res.json = function(obj){
var body = JSON.stringify(obj, replacer, spaces);
// content-type
this.charset = this.charset || 'utf-8';
this.get('Content-Type') || this.set('Content-Type', 'application/json');
return this.send(body);
@@ -234,6 +233,7 @@ res.jsonp = function(obj){
// jsonp
if (callback) {
if (callback instanceof Array) callback = callback[0];
this.set('Content-Type', 'text/javascript');
var cb = callback.replace(/[^\[\]\w$.]/g, '');
body = cb + ' && ' + cb + '(' + body + ');';

View File

@@ -1,7 +1,7 @@
{
"name": "express",
"description": "Sinatra inspired web development framework",
"version": "3.2.6",
"version": "3.3.2",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"contributors": [
{
@@ -22,7 +22,7 @@
}
],
"dependencies": {
"connect": "2.7.11",
"connect": "2.8.2",
"commander": "0.6.1",
"range-parser": "0.0.4",
"mkdirp": "0.3.4",
@@ -30,14 +30,14 @@
"buffer-crc32": "0.2.1",
"fresh": "0.1.0",
"methods": "0.0.1",
"send": "0.1.0",
"send": "0.1.2",
"cookie-signature": "1.0.1",
"debug": "*"
},
"devDependencies": {
"ejs": "*",
"mocha": "*",
"jade": "*",
"jade": "0.30.0",
"hjs": "*",
"stylus": "*",
"should": "*",

View File

@@ -4,10 +4,6 @@ var express = require('../')
, assert = require('assert');
describe('exports', function(){
it('should have .version', function(){
express.should.have.property('version');
})
it('should expose connect middleware', function(){
express.should.have.property('bodyParser');
express.should.have.property('session');
@@ -21,15 +17,15 @@ describe('exports', function(){
it('should expose Router', function(){
express.Router.should.be.a('function');
})
it('should expose the application prototype', function(){
express.application.set.should.be.a('function');
})
it('should expose the request prototype', function(){
express.request.accepts.should.be.a('function');
})
it('should expose the response prototype', function(){
express.response.send.should.be.a('function');
})
@@ -51,7 +47,7 @@ describe('exports', function(){
.get('/')
.expect('bar', done);
})
it('should permit modifying the .response prototype', function(done){
express.response.foo = function(){ this.send('bar'); };
var app = express();

83
test/req.secure.js Normal file
View File

@@ -0,0 +1,83 @@
var express = require('../')
, request = require('./support/http');
describe('req', function(){
describe('.secure', function(){
describe('when X-Forwarded-Proto is missing', function(){
it('should return false when http', function(done){
var app = express();
app.get('/', function(req, res){
res.send(req.secure ? 'yes' : 'no');
});
request(app)
.get('/')
.expect('no', done)
})
})
})
describe('.secure', function(){
describe('when X-Forwarded-Proto is present', function(){
it('should return false when http', function(done){
var app = express();
app.get('/', function(req, res){
res.send(req.secure ? 'yes' : 'no');
});
request(app)
.get('/')
.set('X-Forwarded-Proto', 'https')
.expect('no', done)
})
it('should return true when "trust proxy" is enabled', function(done){
var app = express();
app.enable('trust proxy');
app.get('/', function(req, res){
res.send(req.secure ? 'yes' : 'no');
});
request(app)
.get('/')
.set('X-Forwarded-Proto', 'https')
.expect('yes', done)
})
it('should return false when initial proxy is http', function(done){
var app = express();
app.enable('trust proxy');
app.get('/', function(req, res){
res.send(req.secure ? 'yes' : 'no');
});
request(app)
.get('/')
.set('X-Forwarded-Proto', 'http, https')
.expect('no', done)
})
it('should return true when initial proxy is https', function(done){
var app = express();
app.enable('trust proxy');
app.get('/', function(req, res){
res.send(req.secure ? 'yes' : 'no');
});
request(app)
.get('/')
.set('X-Forwarded-Proto', 'https, http')
.expect('yes', done)
})
})
})
})

View File

@@ -28,7 +28,7 @@ describe('res', function(){
request(app)
.get('/')
.end(function(err, res){
res.headers.should.have.property('content-type', 'application/json; charset=utf-8');
res.headers.should.have.property('content-type', 'application/json');
res.text.should.equal('null');
done();
})
@@ -46,13 +46,13 @@ describe('res', function(){
request(app)
.get('/')
.end(function(err, res){
res.headers.should.have.property('content-type', 'application/json; charset=utf-8');
res.headers.should.have.property('content-type', 'application/json');
res.text.should.equal('["foo","bar","baz"]');
done();
})
})
})
describe('when given an object', function(){
it('should respond with json', function(done){
var app = express();
@@ -64,7 +64,7 @@ describe('res', function(){
request(app)
.get('/')
.end(function(err, res){
res.headers.should.have.property('content-type', 'application/json; charset=utf-8');
res.headers.should.have.property('content-type', 'application/json');
res.text.should.equal('{"name":"tobi"}');
done();
})
@@ -125,7 +125,7 @@ describe('res', function(){
})
})
})
describe('.json(status, object)', function(){
it('should respond with json and set the .statusCode', function(done){
var app = express();
@@ -138,7 +138,7 @@ describe('res', function(){
.get('/')
.end(function(err, res){
res.statusCode.should.equal(201);
res.headers.should.have.property('content-type', 'application/json; charset=utf-8');
res.headers.should.have.property('content-type', 'application/json');
res.text.should.equal('{"id":1}');
done();
})
@@ -157,7 +157,7 @@ describe('res', function(){
.get('/')
.end(function(err, res){
res.statusCode.should.equal(201);
res.headers.should.have.property('content-type', 'application/json; charset=utf-8');
res.headers.should.have.property('content-type', 'application/json');
res.text.should.equal('{"id":1}');
done();
})

View File

@@ -202,7 +202,7 @@ describe('res', function(){
request(app)
.get('/')
.end(function(err, res){
res.headers.should.have.property('content-type', 'application/json; charset=utf-8');
res.headers.should.have.property('content-type', 'application/json');
res.text.should.equal('{"name":"tobi"}');
done();
})