Permalink
Browse files

Prefer this.end over this.res.end so that connect.session will save.

  • Loading branch information...
1 parent c7f7ac9 commit 08861902b8dbf89952590ce47539e307859d1804 @travist committed Sep 16, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 lib/response-stream.js
@@ -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();
@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.