Permalink
Browse files

Set Content-Length header to 0 when redirecting.

  • Loading branch information...
1 parent 1510100 commit b6b03c51cc07e3b67d87dc72eca9a25fe81e4f39 @jaredhanson committed Nov 4, 2012
Showing with 9 additions and 4 deletions.
  1. +1 −0 lib/passport/context/http/actions.js
  2. +8 −4 test/context/http/actions-test.js
View
1 lib/passport/context/http/actions.js
@@ -59,6 +59,7 @@ actions.redirect = function(url, status) {
// Otherwise fall back to native methods
res.statusCode = status || 302;
res.setHeader('Location', url);
+ res.setHeader('Content-Length', '0');
res.end();
}
}
View
12 test/context/http/actions-test.js
@@ -94,7 +94,8 @@ vows.describe('actions').addBatch({
var self = this;
var mockRes = {};
mockRes.setHeader = function(field, value) {
- this.header = field + ': ' + value;
+ this.header = this.header || {};
+ this.header[field] = value;
}
mockRes.end = function() {
self.callback(null, this);
@@ -111,7 +112,8 @@ vows.describe('actions').addBatch({
'should redirect to url': function (err, res) {
assert.equal(res.statusCode, 302);
- assert.equal(res.header, 'Location: http://www.example.com/login');
+ assert.equal(res.header['Location'], 'http://www.example.com/login');
+ assert.equal(res.header['Content-Length'], '0');
},
},
@@ -120,7 +122,8 @@ vows.describe('actions').addBatch({
var self = this;
var mockRes = {};
mockRes.setHeader = function(field, value) {
- this.header = field + ': ' + value;
+ this.header = this.header || {};
+ this.header[field] = value;
}
mockRes.end = function() {
self.callback(null, this);
@@ -137,7 +140,8 @@ vows.describe('actions').addBatch({
'should redirect to url': function (err, res) {
assert.equal(res.statusCode, 303);
- assert.equal(res.header, 'Location: http://www.example.com/login');
+ assert.equal(res.header['Location'], 'http://www.example.com/login');
+ assert.equal(res.header['Content-Length'], '0');
},
},

0 comments on commit b6b03c5

Please sign in to comment.