Comparing version 2.42.0 to 2.43.0
@@ -122,3 +122,3 @@ // Copyright 2010-2012 Mikeal Rogers | ||
var params = initParams(uri, opts, callback) | ||
params.options = extend(params.options, headerlessOptions(options)) | ||
params.options = extend(headerlessOptions(options), params.options) | ||
@@ -125,0 +125,0 @@ if (options.headers) |
@@ -16,16 +16,2 @@ var optional = require('./optional') | ||
// Adapt the sometimes-Async api of tough.CookieJar to our requirements | ||
function RequestJar() { | ||
this._jar = new CookieJar(); | ||
} | ||
RequestJar.prototype.setCookie = function(cookieOrStr, uri, options) { | ||
return this._jar.setCookieSync(cookieOrStr, uri, options || {}); | ||
}; | ||
RequestJar.prototype.getCookieString = function(uri) { | ||
return this._jar.getCookieStringSync(uri); | ||
}; | ||
RequestJar.prototype.getCookies = function(uri) { | ||
return this._jar.getCookiesSync(uri); | ||
}; | ||
exports.jar = function() { | ||
@@ -35,8 +21,10 @@ if (!CookieJar) { | ||
return { | ||
setCookie: function(){}, | ||
getCookieString: function(){}, | ||
getCookies: function(){} | ||
setCookieSync: function(){}, | ||
getCookieStringSync: function(){}, | ||
getCookiesSync: function(){} | ||
}; | ||
} | ||
return new RequestJar(); | ||
var jar = new CookieJar(); | ||
jar._jar = jar; // For backwards compatibility | ||
return jar; | ||
}; |
@@ -18,5 +18,9 @@ var extend = require('util')._extend | ||
var params = constructObject() | ||
if (typeof uri === 'object') params.extend(uri) | ||
if (typeof uri === 'string') params.extend({uri: uri}) | ||
params.extend(options) | ||
if (typeof options === 'object') { | ||
params.extend(options).extend({uri: uri}) | ||
} else if (typeof uri === 'string') { | ||
params.extend({uri: uri}) | ||
} else { | ||
params.extend(uri) | ||
} | ||
return params.done() | ||
@@ -23,0 +27,0 @@ } |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "2.42.0", | ||
"version": "2.43.0", | ||
"author": "Mikeal Rogers <mikeal.rogers@gmail.com>", | ||
@@ -13,0 +13,0 @@ "repository": { |
@@ -111,5 +111,4 @@ # Request — Simplified HTTP client | ||
See (the wikipedia page on HTTP | ||
Tunneling)[http://en.wikipedia.org/wiki/HTTP_tunnel] for more | ||
information. | ||
See [the wikipedia page on HTTP Tunneling](http://en.wikipedia.org/wiki/HTTP_tunnel) | ||
for more information. | ||
@@ -528,4 +527,4 @@ By default, when proxying `http` traffic, request will simply make a | ||
request({url: 'http://www.google.com', jar: j}, function () { | ||
var cookie_string = j.getCookieString(uri); // "key1=value1; key2=value2; ..." | ||
var cookies = j.getCookies(uri); | ||
var cookie_string = j.getCookieStringSync(uri); // "key1=value1; key2=value2; ..." | ||
var cookies = j.getCookiesSync(uri); | ||
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] | ||
@@ -532,0 +531,0 @@ }) |
@@ -213,4 +213,5 @@ var optional = require('./lib/optional') | ||
if (!options) options = {} | ||
self.headers = self.headers ? copy(self.headers) : {} | ||
caseless.httpify(self, self.headers || {}) | ||
caseless.httpify(self, self.headers) | ||
@@ -876,7 +877,7 @@ // Never send proxy-auth to the endpoint! | ||
var targetCookieJar = (self._jar && self._jar.setCookie)?self._jar:globalCookieJar; | ||
var targetCookieJar = (self._jar && self._jar.setCookieSync)?self._jar:globalCookieJar; | ||
var addCookie = function (cookie) { | ||
//set the cookie if it's domain in the href's domain. | ||
try { | ||
targetCookieJar.setCookie(cookie, self.uri.href, {ignoreError: true}); | ||
targetCookieJar.setCookieSync(cookie, self.uri.href, {ignoreError: true}); | ||
} catch (e) { | ||
@@ -1100,2 +1101,5 @@ self.emit('error', e); | ||
}) | ||
dataStream.on("error", function (error) { | ||
self.emit("error", error) | ||
}) | ||
dataStream.on("close", function () {self.emit("close")}) | ||
@@ -1428,7 +1432,7 @@ | ||
} else { | ||
var targetCookieJar = (jar && jar.getCookieString)?jar:globalCookieJar; | ||
var targetCookieJar = (jar && jar.getCookieStringSync)?jar:globalCookieJar; | ||
var urihref = this.uri.href | ||
//fetch cookie in the Specified host | ||
if (targetCookieJar) { | ||
cookies = targetCookieJar.getCookieString(urihref); | ||
cookies = targetCookieJar.getCookieStringSync(urihref); | ||
} | ||
@@ -1435,0 +1439,0 @@ } |
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
210703
1527
544