Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set Content-Length header to 0 when redirecting.

  • Loading branch information...
commit b6b03c51cc07e3b67d87dc72eca9a25fe81e4f39 1 parent 1510100
Jared Hanson authored
1  lib/passport/context/http/actions.js
View
@@ -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();
}
}
12 test/context/http/actions-test.js
View
@@ -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');
},
},
Please sign in to comment.
Something went wrong with that request. Please try again.