Skip to content

Commit

Permalink
Properly set cookies during redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
vpulim committed Mar 14, 2012
1 parent 3b9f0fd commit fddbd6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Request.prototype.init = function (options) {
self.setHost = true
}

self.jar(options.jar)
self.jar(self._jar || options.jar)

if (!self.uri.pathname) {self.uri.pathname = '/'}
if (!self.uri.port) {
Expand Down
8 changes: 6 additions & 2 deletions tests/test-redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ s.listen(s.port, function () {

s.on('/'+label, function (req, res) {
hits[label] = true;
res.writeHead(code, {'location':server + '/'+landing})
res.writeHead(code, {
'location':server + '/'+landing,
'set-cookie': 'ham=eggs'
})
res.end()
})

Expand All @@ -32,7 +35,8 @@ s.listen(s.port, function () {
return;
}
// Make sure the cookie doesn't get included twice, see #139:
assert.equal(req.headers.cookie, 'foo=bar; quux=baz');
// Make sure cookies are set properly after redirect
assert.equal(req.headers.cookie, 'foo=bar; quux=baz; ham=eggs');
hits[landing] = true;
res.writeHead(200)
res.end(landing)
Expand Down

0 comments on commit fddbd6e

Please sign in to comment.