Skip to content

Commit

Permalink
Merge pull request #589 from wpreul/master
Browse files Browse the repository at this point in the history
Prevent setting headers after they are sent
  • Loading branch information
mikeal committed Jul 9, 2013
2 parents 8598f64 + fac9da1 commit c12a116
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions index.js
Expand Up @@ -675,11 +675,11 @@ Request.prototype.onResponse = function (response) {
var addCookie = function (cookie) {
if (self._jar){
if(self._jar.add){
self._jar.add(new Cookie(cookie))
self._jar.add(new Cookie(cookie))
}
else cookieJar.add(new Cookie(cookie))
}
else cookieJar.add(new Cookie(cookie))
}

}

if (response.headers['set-cookie'] && (!self._disableCookies)) {
Expand Down Expand Up @@ -917,7 +917,7 @@ Request.prototype.pipeDest = function (dest) {
dest.headers['content-length'] = response.headers['content-length']
}
}
if (dest.setHeader) {
if (dest.setHeader && !dest.headersSent) {
for (var i in response.headers) {
dest.setHeader(i, response.headers[i])
}
Expand Down

0 comments on commit c12a116

Please sign in to comment.