Permalink
Browse files

Fixing the set-cookie header

  • Loading branch information...
1 parent 706929d commit 176417698a84c53c0a69bdfd2a05a2942919816c @jeromegn jeromegn committed Apr 30, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 main.js
View
11 main.js
@@ -417,11 +417,14 @@ Request.prototype.start = function () {
self.timeoutTimer = null
}
+ var addCookie = function(cookie){
+ if (self._jar) self._jar.add(new Cookie(cookie))
+ else cookieJar.add(new Cookie(cookie))
+ }
+
if (response.headers['set-cookie'] && (!self._disableCookies)) {
- response.headers['set-cookie'].forEach(function(cookie) {
- if (self._jar) self._jar.add(new Cookie(cookie))
- else cookieJar.add(new Cookie(cookie))
- })
+ if (Array.isArray(response.headers['set-cookie'])) response.headers['set-cookie'].forEach(addCookie)
+ else addCookie(response.headers['set-cookie'])
}
if (response.statusCode >= 300 && response.statusCode < 400 &&

0 comments on commit 1764176

Please sign in to comment.