Comparing version 2.9.2 to 2.9.3
72
main.js
@@ -159,7 +159,7 @@ // Copyright 2010-2011 Mikeal Rogers | ||
if (cookies) { | ||
var cookieString = cookies.map(function (c) { | ||
return c.name + "=" + c.value; | ||
}).join("; "); | ||
self.headers.Cookie = cookieString; | ||
var cookieString = cookies.map(function (c) { | ||
return c.name + "=" + c.value; | ||
}).join("; "); | ||
self.headers.Cookie = cookieString; | ||
} | ||
@@ -267,3 +267,3 @@ | ||
} else if (self.multipart) { | ||
self.body = []; | ||
self.body = [] | ||
self.headers['content-type'] = 'multipart/related;boundary="frontier"' | ||
@@ -280,26 +280,26 @@ if (!self.multipart.forEach) throw new Error('Argument error, options.multipart.') | ||
}) | ||
preamble += '\r\n'; | ||
self.body.push(new Buffer(preamble)); | ||
self.body.push(new Buffer(body)); | ||
self.body.push(new Buffer('\r\n')); | ||
preamble += '\r\n' | ||
self.body.push(new Buffer(preamble)) | ||
self.body.push(new Buffer(body)) | ||
self.body.push(new Buffer('\r\n')) | ||
}) | ||
self.body.push(new Buffer('--frontier--')); | ||
self.body.push(new Buffer('--frontier--')) | ||
} | ||
if (self.body) { | ||
var length = 0; | ||
var length = 0 | ||
if (!Buffer.isBuffer(self.body)) { | ||
if (Array.isArray(self.body)) { | ||
for (var i = 0; i < self.body.length; i++) { | ||
length += self.body[i].length; | ||
length += self.body[i].length | ||
} | ||
} else { | ||
self.body = new Buffer(self.body) | ||
length = self.body.length; | ||
length = self.body.length | ||
} | ||
} else { | ||
length = self.body.length; | ||
length = self.body.length | ||
} | ||
if (length) { | ||
self.headers['content-length'] = length; | ||
self.headers['content-length'] = length | ||
} else { | ||
@@ -313,3 +313,3 @@ throw new Error('Argument error, options.body.') | ||
, httpModules = self.httpModules || {} | ||
; | ||
self.httpModule = httpModules[protocol] || defaultModules[protocol] | ||
@@ -337,3 +337,4 @@ | ||
self.method = self.method || 'GET' | ||
if (log) log('%method %uri.href', self) | ||
self.href = self.uri.href | ||
if (log) log('%method %href', self) | ||
self.req = self.httpModule.request(self, function (response) { | ||
@@ -355,12 +356,6 @@ self.response = response | ||
if (response.headers['set-cookie'] && (!self._disableCookies)) { | ||
response.headers['set-cookie'].forEach(function(cookie) { | ||
if (self.jar) { | ||
// custom defined jar | ||
self.jar.add(new Cookie(cookie)); | ||
} | ||
else { | ||
// add to the global cookie jar if user don't define his own | ||
cookieJar.add(new Cookie(cookie)); | ||
} | ||
}); | ||
response.headers['set-cookie'].forEach(function(cookie) { | ||
if (self.jar) self.jar.add(new Cookie(cookie)) | ||
else cookieJar.add(new Cookie(cookie)) | ||
}) | ||
} | ||
@@ -384,4 +379,7 @@ | ||
self.uri = response.headers.location | ||
self.redirects.push( { statusCode : response.statusCode, | ||
redirectUri: response.headers.location }) | ||
self.redirects.push( | ||
{ statusCode : response.statusCode | ||
, redirectUri: response.headers.location | ||
} | ||
) | ||
delete self.req | ||
@@ -485,9 +483,9 @@ delete self.agent | ||
self.timeoutTimer = setTimeout(function() { | ||
self.req.abort() | ||
var e = new Error("ETIMEDOUT") | ||
e.code = "ETIMEDOUT" | ||
self.emit("error", e) | ||
self.req.abort() | ||
var e = new Error("ETIMEDOUT") | ||
e.code = "ETIMEDOUT" | ||
self.emit("error", e) | ||
}, self.timeout) | ||
} | ||
self.req.on('error', clientErrorHandler) | ||
@@ -524,4 +522,4 @@ } | ||
self.body.forEach(function(part) { | ||
self.write(part); | ||
}); | ||
self.write(part) | ||
}) | ||
} else { | ||
@@ -528,0 +526,0 @@ self.write(self.body) |
{ "name" : "request" | ||
, "description" : "Simplified HTTP request client." | ||
, "tags" : ["http", "simple", "util", "utility"] | ||
, "version" : "2.9.2" | ||
, "version" : "2.9.3" | ||
, "author" : "Mikeal Rogers <mikeal.rogers@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "repository" : |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113736
1721