Skip to content

Commit

Permalink
Prefer this.end over this.res.end so that connect.session will save.
Browse files Browse the repository at this point in the history
  • Loading branch information
travist committed Sep 16, 2012
1 parent c7f7ac9 commit 0886190
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/response-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,24 @@ ResponseStream.prototype.write = function (data) {

ResponseStream.prototype.redirect = function(path, status) {
var url = '';

if(~path.indexOf('://')) {
url = path;
} else {
url += this.req.connection.encrypted ? 'https://' : 'http://';
url += this.req.headers.host;
url += (path[0] === '/') ? path : '/' + path;
url += (path[0] === '/') ? path : '/' + path;
}

this.res.writeHead(status || 302, {
'Location': url
});
this.res.end();

// Prefer this.end over this.res.end so that connect.session will save.
if ((typeof this.end)==='function') {
this.end();
}
else {
this.res.end();

This comment has been minimized.

Copy link
@davidrslopes

davidrslopes Nov 15, 2012

As of Union version 0.3.5 res is renamed response like so:
this.response.end();

}
};

0 comments on commit 0886190

Please sign in to comment.